org.apache.commons.lang3.time.StopWatch.reset()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中org.apache.commons.lang3.time.StopWatch.reset()方法的一些代码示例,展示了StopWatch.reset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.reset()方法的具体详情如下:
包路径:org.apache.commons.lang3.time.StopWatch
类名称:StopWatch
方法名:reset

StopWatch.reset介绍

[英]Resets the stopwatch. Stops it if need be.

This method clears the internal values to allow the object to be reused.
[中]重置秒表。必要时停止。
此方法清除内部值以允许重用对象。

代码示例

代码示例来源:origin: apache/hbase

StopWatch stopWatch = new StopWatch();
stopWatch.reset();
try {
 tableName = region.getTable();

代码示例来源:origin: apache/hbase

private static void timerTests(final CellBlockBuilder builder, final int count, final int size,
  final Codec codec, final CompressionCodec compressor) throws IOException {
 final int cycles = 1000;
 StopWatch timer = new StopWatch();
 timer.start();
 for (int i = 0; i < cycles; i++) {
  timerTest(builder, timer, count, size, codec, compressor, false);
 }
 timer.stop();
 LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + false + ", count="
   + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
 timer.reset();
 timer.start();
 for (int i = 0; i < cycles; i++) {
  timerTest(builder, timer, count, size, codec, compressor, true);
 }
 timer.stop();
 LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + true + ", count="
   + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testGetStartTime() {
  final long beforeStopWatch = System.currentTimeMillis();
  final StopWatch watch = new StopWatch();
  try {
    watch.getStartTime();
    fail("Calling getStartTime on an unstarted StopWatch should throw an exception");
  } catch (final IllegalStateException expected) {
    // expected
  }
  watch.start();
  try {
    watch.getStartTime();
    assertTrue(watch.getStartTime() >= beforeStopWatch);
  } catch (final IllegalStateException ex) {
    fail("Start time should be available: " + ex.getMessage());
  }
  watch.reset();
  try {
    watch.getStartTime();
    fail("Calling getStartTime on a reset, but unstarted StopWatch should throw an exception");
  } catch (final IllegalStateException expected) {
    // expected
  }
}

代码示例来源:origin: apache/usergrid

timer.reset();

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testStopWatchSimple() {
  final StopWatch watch = new StopWatch();
  watch.start();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.stop();
  final long time = watch.getTime();
  assertEquals(time, watch.getTime());
  assertTrue(time >= 500);
  assertTrue(time < 700);
  watch.reset();
  assertEquals(0, watch.getTime());
}

代码示例来源:origin: apache/usergrid

timer.reset();

代码示例来源:origin: apache/hbase

StopWatch stopWatch = new StopWatch();
for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {
 stopWatch.reset();
 startKey = region.getStartKey();

代码示例来源:origin: apache/usergrid

timer.reset();

代码示例来源:origin: winder/Universal-G-Code-Sender

this.streamStopWatch.reset();
this.streamStopWatch.start();
this.numCommands = 0;
} catch(Exception e) {
  this.isStreaming = false;
  this.streamStopWatch.reset();
  this.comm.cancelSend();
  throw e;

代码示例来源:origin: xvik/dropwizard-guicey

@Override
public void lifeCycleStopping(final LifeCycle event) {
  timer.reset();
  log("Stopping Jetty...");
}

代码示例来源:origin: ru.vyarus/dropwizard-guicey

@Override
public void lifeCycleStopping(final LifeCycle event) {
  timer.reset();
  log("Stopping Jetty...");
}

代码示例来源:origin: de.aosd.clazzfish/clazzfish-monitor

/**
 * Reset.
 *
 * @see StopWatch#reset()
 */
@Override
public void reset() {
  super.reset();
  this.nanoStartTime = 0L;
  this.nanoEndTime = 0L;
}

代码示例来源:origin: org.patterntesting/patterntesting-rt

/**
 * Reset.
 *
 * @see org.apache.commons.lang3.time.StopWatch#reset()
 */
@Override
public void reset() {
  super.reset();
  this.nanoStartTime = 0L;
  this.nanoEndTime = 0L;
}

代码示例来源:origin: rmagen/elastic-gremlin

public Timer(String name) {
  this.name = name;
  sw.reset();
}

代码示例来源:origin: org.apache.hbase/hbase-client

private static void timerTests(final CellBlockBuilder builder, final int count, final int size,
  final Codec codec, final CompressionCodec compressor) throws IOException {
 final int cycles = 1000;
 StopWatch timer = new StopWatch();
 timer.start();
 for (int i = 0; i < cycles; i++) {
  timerTest(builder, timer, count, size, codec, compressor, false);
 }
 timer.stop();
 LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + false + ", count="
   + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
 timer.reset();
 timer.start();
 for (int i = 0; i < cycles; i++) {
  timerTest(builder, timer, count, size, codec, compressor, true);
 }
 timer.stop();
 LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + true + ", count="
   + count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
}

代码示例来源:origin: fhoeben/hsac-fitnesse-fixtures

private int getNextInterval(StopWatch loopTimer) {
  int nextInterval;
  long loopTime = loopTimer.getTime();
  nextInterval = Math.max(0, ((int) (repeatInterval - loopTime)));
  loopTimer.reset();
  return nextInterval;
}

代码示例来源:origin: us.ihmc/joctomap

public void updateNodesNormals(Collection<NormalOcTreeNode> nodesToUpdate, NormalEstimationParameters normalEstimationParameters)
{
 if (reportTime)
 {
   stopWatch.reset();
   stopWatch.start();
 }
 Stream<NormalOcTreeNode> nodeStream = computeNormalsInParallel ? nodesToUpdate.parallelStream() : nodesToUpdate.stream();
 nodeStream.forEach(node -> NormalEstimationTools.computeNodeNormalRansac(root, node, normalEstimationParameters));
 if (root != null)
   updateInnerNormalsRecursive(root, 0);
 if (reportTime)
 {
   System.out.println(name + ": Normal computation took: " + JOctoMapTools.nanoSecondsToSeconds(stopWatch.getNanoTime()) + " sec.");
 }
}

代码示例来源:origin: us.ihmc/joctomap

public void insertScanCollection(ScanCollection scanCollection, boolean insertMiss, Set<NormalOcTreeNode> updatedLeavesToPack, Set<OcTreeKey> deletedLeavesToPack)
{
 if (reportTime)
 {
   stopWatch.reset();
   stopWatch.start();
 }
 scanCollection.forEach(scan -> insertScan(scan, insertMiss, updatedLeavesToPack, deletedLeavesToPack));
 if (reportTime)
 {
   System.out.println(name + ": ScanCollection integration took: " + JOctoMapTools.nanoSecondsToSeconds(stopWatch.getNanoTime()) + " sec. (number of points: " + scanCollection.getNumberOfPoints() + ").");
 }
}

代码示例来源:origin: org.kie/business-central-tests-rest

protected static void deleteAllSpaces() {
  Collection<Space> spaces = client.getSpaces();
  log.info("Deleting {} spaces", spaces.size());
  spaces.forEach(space -> {
    stopWatch.reset();
    stopWatch.start();
    try {
      client.deleteSpace(space.getName());
    } finally {
      stopWatch.stop();
      log.debug("Deleting space '{}' took {} ms", space.getName(), stopWatch.getTime());
    }
  });
}

代码示例来源:origin: org.kie/kie-wb-tests-rest

protected static void deleteAllSpaces() {
  Collection<Space> spaces = client.getSpaces();
  log.info("Deleting {} spaces", spaces.size());
  spaces.forEach(space -> {
    stopWatch.reset();
    stopWatch.start();
    try {
      client.deleteSpace(space.getName());
    } finally {
      stopWatch.stop();
      log.debug("Deleting space '{}' took {} ms", space.getName(), stopWatch.getTime());
    }
  });
}

相关文章