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

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

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

StopWatch.suspend介绍

[英]Suspend the stopwatch for later resumption.

This method suspends the watch until it is resumed. The watch will not include time between the suspend and resume calls in the total time.
[中]暂停秒表,以便稍后恢复。
此方法暂停手表,直到它恢复。手表将不包括暂停和恢复通话之间的总时间。

代码示例

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

watch.suspend();
try {
  final long currentNanos = System.nanoTime();

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

@Test
public void testLang315() {
  final StopWatch watch = new StopWatch();
  watch.start();
  try {
    Thread.sleep(200);
  } catch (final InterruptedException ex) {
  }
  watch.suspend();
  final long suspendTime = watch.getTime();
  try {
    Thread.sleep(200);
  } catch (final InterruptedException ex) {
  }
  watch.stop();
  final long totalTime = watch.getTime();
  assertTrue(suspendTime == totalTime);
}

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

@Test
public void testStopWatchSuspend() {
  final StopWatch watch = new StopWatch();
  watch.start();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.suspend();
  final long suspendTime = watch.getTime();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.resume();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.stop();
  final long totalTime = watch.getTime();
  assertTrue(suspendTime >= 500);
  assertTrue(suspendTime < 700);
  assertTrue(totalTime >= 1000);
  assertTrue(totalTime < 1300);
}

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

@Test
public void testBooleanStates() {
  final StopWatch watch = new StopWatch();
  assertFalse(watch.isStarted());
  assertFalse(watch.isSuspended());
  assertTrue(watch.isStopped());
  watch.start();
  assertTrue(watch.isStarted());
  assertFalse(watch.isSuspended());
  assertFalse(watch.isStopped());
  watch.suspend();
  assertTrue(watch.isStarted());
  assertTrue(watch.isSuspended());
  assertFalse(watch.isStopped());
  watch.stop();
  assertFalse(watch.isStarted());
  assertFalse(watch.isSuspended());
  assertTrue(watch.isStopped());
}

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

@Override
public void pauseStreaming() throws Exception {
  this.dispatchConsoleMessage(MessageType.INFO,"\n**** Pausing file transfer. ****\n\n");
  pauseStreamingEvent();
  this.comm.pauseSend();
  this.setCurrentState(COMM_SENDING_PAUSED);
  if (streamStopWatch.isStarted() && !streamStopWatch.isSuspended()) {
    this.streamStopWatch.suspend();
  }
}

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

watch.suspend();
  fail("Calling suspend on an unstarted StopWatch should throw an exception. ");
} catch (final IllegalStateException ise) {

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

public void stop() {
  sw.suspend();
  long time = sw.getTime() - lastRun;
  if (time > longestRun) longestRun = time;
  lastRun = time;
  numOfRuns++;
}

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

/**
 * Pauses named timer (stopping measurement), can be resumed later.
 * @param name name of timer to pause.
 * @return time in milliseconds since timer was started.
 */
public long pauseTimer(String name) {
  StopWatch sw = getStopWatch(name);
  sw.suspend();
  return sw.getTime();
}

代码示例来源:origin: jhpoelen/eol-globi-data

public String logProgress(int counter, StopWatch stopWatch) {
  stopWatch.suspend();
  String msg = "linked [%d] reference(s) in [%.1f] s  at rate of [%.1f] references/s)";
  stopWatch.resume();
  return String.format(msg, counter, stopWatch.getTime() / 1000.0, 1000.0 * counter / stopWatch.getTime());
}

代码示例来源:origin: mjugo/StreamingRec

testTime.start();
inBetweenTrainTime.start();
inBetweenTrainTime.suspend();
    testTime.suspend();
    inBetweenTrainTime.resume();
    testee.train(Collections.singletonList(articleEvent), Collections.EMPTY_LIST);
    inBetweenTrainTime.suspend();
    testTime.resume();
  } else {
    testTime.suspend();
    inBetweenTrainTime.resume();
    testee.train(Collections.EMPTY_LIST, Collections.singletonList(wpC.clickData));
    inBetweenTrainTime.suspend();
    testTime.resume();

相关文章