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

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

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

StopWatch.toSplitString介绍

[英]Gets a summary of the split time that the stopwatch recorded as a string.

The format used is ISO 8601-like, hours:minutes:seconds.milliseconds.
[中]获取秒表记录为字符串的分割时间的摘要。
使用的格式类似于ISO 8601,小时:分钟:秒。毫秒。

代码示例

代码示例来源: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.onehippo.cms7/hippo-repository-engine

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

相关文章