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

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

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

StopWatch.split介绍

[英]Split the time.

This method sets the stop time of the watch to allow a time to be extracted. The start time is unaffected, enabling #unsplit() to continue the timing from the original start point.
[中]分开时间。
此方法设置手表的停止时间,以便提取时间。开始时间不受影响,允许#unsplit()从原始开始点继续计时。

代码示例

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

@Test
public void testStopWatchSplit() {
  final StopWatch watch = new StopWatch();
  watch.start();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.split();
  final long splitTime = watch.getSplitTime();
  final String splitStr = watch.toSplitString();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.unsplit();
  try {
    Thread.sleep(550);
  } catch (final InterruptedException ex) {
  }
  watch.stop();
  final long totalTime = watch.getTime();
  assertEquals("Formatted split string not the correct length",
      splitStr.length(), 12);
  assertTrue(splitTime >= 500);
  assertTrue(splitTime < 700);
  assertTrue(totalTime >= 1500);
  assertTrue(totalTime < 1900);
}

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

watch.split();
  fail("Calling split on a non-running StopWatch should throw an exception. ");
} catch (final IllegalStateException ise) {

代码示例来源:origin: dhis2/dhis2-core

/**
 * Yields the elapsed time since the Clock was started as an HMS String.
 * @return the elapsed time.
 */
public String time()
{
  super.split();
  
  return DurationFormatUtils.formatDurationHMS( super.getSplitTime() );
}

代码示例来源:origin: dhis2/dhis2-core

/**
   * Timestamps the given message using the elapsed time of this Clock and
   * logs it using the logger.
   * @param message the message to log.
   * @return this Clock.
   */
  public Clock logTime( String message )
  {
    super.split();
    
    String time = DurationFormatUtils.formatDurationHMS( super.getSplitTime() ); 
    
    String msg = message + SEPARATOR + time;
    
    if ( log != null )
    {
      log.info( msg );
    }
    else
    {
      defaultLog.info( msg );
    }
    
    return this;
  }
}

代码示例来源:origin: org.genesys-pgr/genesys-geotools

stopWatch.split();
long processingTime = stopWatch.getSplitTime();
if (debug) {

代码示例来源:origin: com.atlassian.jira/jira-core

watch.split();
watch.split();

代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine

stopWatch.split();
AutoExportServiceImpl.log.debug("Events processed in {}", stopWatch.toSplitString());

相关文章