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

x33g5p2x  于2022-01-30 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(102)

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

StopWatch.getTime介绍

[英]Get the time on the stopwatch.

This is either the time between the start and the moment this method is called, or the amount of time between start and stop.
[中]记下秒表上的时间。
这是启动和调用此方法之间的时间,或者是启动和停止之间的时间。

代码示例

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>
 * Gets a summary of the time that the stopwatch recorded as a string.
 * </p>
 * 
 * <p>
 * The format used is ISO8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>.
 * </p>
 * 
 * @return the time as a String
 */
public String toString() {
  return DurationFormatUtils.formatDurationHMS(getTime());
}

代码示例来源:origin: stackoverflow.com

StopWatch stopWatch = new StopWatch();
stopWatch.getTime();
stopWatch.stop();
stopWatch.start();

代码示例来源:origin: zstackio/zstack

logger.trace(String.format("shell command[%s] costs %sms to finish", command, watch.getTime()));

代码示例来源:origin: forcedotcom/phoenix

/**
 * Log a message to persistent storage. Elapsed time since start is added.
 * @param message
 * @throws IOException
 */
public void instanceLog(String message) throws IOException {
  long elapsedMs = getStopWatch().getTime();
  String displayTime = elapsedMs < 1000 ? elapsedMs + " ms" : elapsedMs / 1000 + " sec";
  message = getDateTime() + " (" + displayTime + ") : " + message + "\n";
  System.out.println(message);
  getFileOutputStream().write(message.getBytes());
}

代码示例来源:origin: zstackio/zstack

if (logger.isTraceEnabled()) {
  if (script != null) {
    logger.trace(String.format("execute script[%s], cost time:%s", script.scriptName, watch.getTime()));
  } else {
    String cmd = StringUtils.join(CollectionUtils.transformToList(commands, new Function<String, SshRunner>() {
        "command: {2}\n",
        "cost time: {3}ms\n"
    ).format(hostname, port, cmd, watch.getTime());
    logger.trace(info);

代码示例来源:origin: org.carewebframework/org.carewebframework.ui.core

/**
 * Returns the execution time in milliseconds of the thread.
 *
 * @return long elapsed
 */
public long getElapsed() {
  return watch.getTime();
}

代码示例来源:origin: org.zaproxy/zap

/**
 * Gets the running time, in milliseconds, of the analyser.
 *
 * @return the running time of the analyser.
 * @since 2.7.0
 */
public long getRunningTime() {
  return stopWatch.getTime();
}

代码示例来源:origin: naver/ngrinder

/**
 * Test method for {@link ThreadUtils#sleep(long)}.
 */
@Test
public void testSleep() {
  StopWatch watch = new StopWatch();
  watch.start();
  ThreadUtils.sleep(1000);
  watch.stop();
  assertThat(watch.getTime()).isGreaterThanOrEqualTo(1000);
  assertThat(watch.getTime()).isLessThan(3000);
}

代码示例来源:origin: omero/blitz

private synchronized void updateStats(StopWatch sw, long uploadedBytes) {
  totalTime += sw.getTime();
  totalBytes += uploadedBytes;
  imageContainerSize -= uploadedBytes;
  if (totalTime > 0) {
    float averageBps = totalBytes / ((float) totalTime / 1000);
    timeLeft = (long) Math
        .ceil((imageContainerSize / averageBps) * 1000);
  }
}

代码示例来源:origin: OpenClinica/OpenClinica

public void stop() {
  if (LOG.isDebugEnabled()) {
    stopwatch.stop();
    long totalTime = stopwatch.getTime();
    LOG.debug(String.format(STOP_LABEL, name, totalTime / 60000,  (float) (totalTime % 60000) / 1000));
  }
}

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

public void progress() {
    counter.incrementAndGet();
    if (counter.get() % reportInterval == 0) {
      long time = stopWatch.getTime() / 1000;
      listener.onProgress(String.format("handled [%d] in [%d]s ([%.1f] /s)", counter.get(), time, (float) counter.get() / time));
    }

  }
}

代码示例来源:origin: stackoverflow.com

StopWatch myMapTimer = new StopWatch();
HashMap<Integer, Integer> hashMap = new HashMap<>();

myMapTimer.start();
for (int i = 0; i < numElements; i++)
  hashMap.put(i, i);
myMapTimer.stop();

System.out.println(myMapTimer.getTime()); // time will be in milliseconds

代码示例来源:origin: stackoverflow.com

StopWatch sw = new StopWatch();
 sw.start();
 // query you want to measure the time for
 sw.stop(); 
 long timeInMilliseconds = sw.getTime();
 System.out.println("Time in ms is: " + timeInMilliseconds ); 
 // or maybe log it if you like?

代码示例来源:origin: com.atlassian.addon.connect.hercules/hercules-ac

protected ScanResult matchForPatterns(final BufferedReader reader, final Date date)
      throws IOException
  {
    LOGGER.debug("start matching for patterns");

    final StopWatch sw = new StopWatch();
    sw.start();
    final Map<String, PatternMatchSet> results = match(reader, date);

    LOGGER.debug("results found: {}", results.size());

    return new DefaultScanResult(scanItem, results.values(), Lists.<PropertyScanResult>newArrayList(), sw.getTime());
  }
}

代码示例来源:origin: stackoverflow.com

StopWatch stopWatch = new StopWatch();
stopWatch.start();

// do stuff

stopWatch.stop();

long nanos = stopWatch.getNanos(); // time in nanoseconds
long millis = stopWatch.getTime(); // time in millis

代码示例来源:origin: stackoverflow.com

StopWatch stopWatch = new StopWatch();
stopWatch.start();
...
stopWatch.suspend();
...
stopWatch.resume();
...
stopWatch.stop():

long elapsed = stopWatch.getTime();

代码示例来源:origin: stackoverflow.com

protected int countImagesWithProcessor(PDDocument pdf) throws IOException {
  StopWatch stopWatch = new StopWatch();
  stopWatch.start();

  PdfImageCounter counter = new PdfImageCounter();
  for (PDPage pdPage : pdf.getPages()) {
    counter.processPage(pdPage);
  }

  stopWatch.stop();
  int imageCount = counter.getDocumentImageCount();
  log.info("Images counted: time={}s,imageCount={}", stopWatch.getTime() / 1000, imageCount);
  return imageCount;
}

代码示例来源:origin: com.atlassian.confluence/confluence-selenium-test

private void waitForHistoryLink(final String group, final String jobId, int waitTime)
{
  StopWatch retryStopWatch = new StopWatch();
  retryStopWatch.start();
  while(!jobAdmin.isHistoryLinkPresent(group, jobId))
  {
    if(retryStopWatch.getTime() > waitTime)
      fail("History link for [" + group + "#" + jobId + "] did not appear");
    TimeUtils.pause(200, TimeUnit.MILLISECONDS);
    jobAdmin.open();
  }
}

代码示例来源:origin: omero/blitz

void report() {
  boolean report = config.sendReport.get();
  boolean files = config.sendFiles.get();
  boolean logs = config.sendLogFile.get();
  if (report) {
    handler.update(null, new ImportEvent.DEBUG_SEND(files, logs));
  }
  library.notifyObservers(new ImportEvent.IMPORT_SUMMARY(sw.getTime(),
      handler.errorCount()));
}

代码示例来源:origin: apache/attic-whirr

private void runTeraSort() throws Exception {
 StopWatch stopWatch = new StopWatch();
 TeraSort teraSort = new TeraSort();
 teraSort.setConf(controller.getJobConf());
 LOG.info("Starting TeraSort");
 stopWatch.start();
 teraSort.run(new String[] { "input", "output" });
 stopWatch.stop();
 LOG.info("TeraSort took {} ms", stopWatch.getTime());
}

相关文章