com.google.common.base.Stopwatch.elapsedMillis()方法的使用及代码示例

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

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

Stopwatch.elapsedMillis介绍

[英]Returns the current elapsed time shown on this stopwatch, expressed in milliseconds, with any fraction rounded down. This is identical to elapsed(TimeUnit.MILLISECONDS).
[中]返回此秒表上显示的当前运行时间,以毫秒为单位,任何分数向下舍入。这与已用时间(时间单位为毫秒)相同。

代码示例

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

Stopwatch stopwatch = Stopwatch.createStarted();
doSomething();
stopwatch.stop(); // optional

long millis = stopwatch.elapsedMillis();

log.info("that took: " + stopwatch); // formatted string like "12.3 ms"

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

@Override
  public void finish(CuboidResult result) {
    Stopwatch stopwatch = new Stopwatch().start();
    int nRetries = 0;
    while (!outputQueue.offer(result)) {
      nRetries++;
      long sleepTime = stopwatch.elapsedMillis();
      if (sleepTime > 3600000L) {
        stopwatch.stop();
        throw new RuntimeException(
            "OutputQueue Full. Cannot offer to the output queue after waiting for one hour!!! Current queue size: "
                + outputQueue.size());
      }
      logger.warn("OutputQueue Full. Queue size: " + outputQueue.size() + ". Total sleep time : " + sleepTime
          + ", and retry count : " + nRetries);
      try {
        Thread.sleep(5000L);
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    stopwatch.stop();
  }
}

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

@Test
public void createDirectChildrenCacheStressTest() {
  Stopwatch sw = new Stopwatch();
  sw.start();
  Set<Long> cuboidSet = generateMassCuboidSet();
  System.out.println("Time elapsed for creating sorted cuboid list: " + sw.elapsedMillis());
  sw.reset();
  sw.start();
  checkDirectChildrenCacheStressTest(CuboidStatsUtil.createDirectChildrenCache(cuboidSet));
  System.out.println("Time elapsed for creating direct children cache: " + sw.elapsedMillis());
  sw.stop();
}

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

logger.info("Dogged Cube Build2 splits complete, took " + sw.elapsedMillis() + " ms");
} catch (Throwable e) {
  logger.error("Dogged Cube Build2 error", e);
  sw.stop();
  builderPool.shutdownNow();
  logger.info("Dogged Cube Build2 end, totally took " + sw.elapsedMillis() + " ms");
  logger.info("Dogged Cube Build2 return");

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

logger.info("Cuboid {} has {} rows, build takes {}ms", cuboidId, count, sw.elapsedMillis());
return updateCuboidResult(cuboidId, newGridTable, count, sw.elapsedMillis(), 0);

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

stopwatch.start();
long estimateBytes = GTAggregateScanner.estimateSizeOfAggrCache(key, values, map.size());
estimateMillis += stopwatch.elapsedMillis();
stopwatch.reset();
actualMillis += stopwatch.elapsedMillis();
stopwatch.reset();

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

logger.info("Cuboid {} has {} rows, build takes {}ms", baseCuboidId, count, sw.elapsedMillis());
logger.info("Wild estimate of base aggr cache is {} MB", mbEstimateBaseAggrCache);
return updateCuboidResult(baseCuboidId, baseCuboid, count, sw.elapsedMillis(), 0,
    input.inputConverterUnit.ifChange());

代码示例来源:origin: caskdata/cdap

@Override
 protected T computeNext() {
  if (stopwatch.elapsedMillis() < timeBoundMillis && delegate.hasNext()) {
   return delegate.next();
  }
  return endOfData();
 }
}

代码示例来源:origin: co.cask.cdap/cdap-common

@Override
 protected T computeNext() {
  if (stopwatch.elapsedMillis() < timeBoundMillis && delegate.hasNext()) {
   return delegate.next();
  }
  return endOfData();
 }
}

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

Stopwatch stopwatch = new Stopwatch().start();
doSomething();
stopwatch.stop(); // optional

long millis = stopwatch.elapsedMillis();

log.info("that took: " + stopwatch); // formatted string like "12.3 ms"

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

Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
calculate();
stopwatch.stop(); // optional

long Seconds= stopwatch.elapsedMillis() / 1000000; // equals 1 second

代码示例来源:origin: caskdata/tephra

private void appendToLog(List<TransactionEdit> edits) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edits);
  txMetricsCollector.rate("wal.append.count", edits.size());
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: org.apache.tephra/tephra-core

/**
 * Starts a long transaction with a client id.
 */
public Transaction startLong(String clientId) {
 Preconditions.checkArgument(clientId != null, "clientId must not be null");
 txMetricsCollector.rate("start.long");
 Stopwatch timer = new Stopwatch().start();
 long expiration = getTxExpiration(defaultLongTimeout);
 Transaction tx = startTx(expiration, TransactionType.LONG, clientId);
 txMetricsCollector.histogram("start.long.latency", (int) timer.elapsedMillis());
 return tx;
}

代码示例来源:origin: org.apache.tephra/tephra-core

private void appendToLog(List<TransactionEdit> edits) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edits);
  txMetricsCollector.rate("wal.append.count", edits.size());
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: co.cask.tephra/tephra-core

private void appendToLog(List<TransactionEdit> edits) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edits);
  txMetricsCollector.rate("wal.append.count", edits.size());
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: org.apache.tephra/tephra-core

private void appendToLog(TransactionEdit edit) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edit);
  txMetricsCollector.rate("wal.append.count");
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: co.cask.tephra/tephra-core

private void appendToLog(TransactionEdit edit) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edit);
  txMetricsCollector.rate("wal.append.count");
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: caskdata/tephra

private void appendToLog(TransactionEdit edit) {
 try {
  Stopwatch timer = new Stopwatch().start();
  currentLog.append(edit);
  txMetricsCollector.rate("wal.append.count");
  txMetricsCollector.histogram("wal.append.latency", (int) timer.elapsedMillis());
 } catch (IOException ioe) {
  abortService("Error appending to transaction log", ioe);
 }
}

代码示例来源:origin: caskdata/tephra

/**
 * Start a long transaction. Long transactions and do not participate in conflict detection. Also, aborting a long
 * transaction moves it to the invalid list because we assume that its writes cannot be rolled back.
 */
public Transaction startLong() {
 txMetricsCollector.rate("start.long");
 Stopwatch timer = new Stopwatch().start();
 long expiration = getTxExpiration(defaultLongTimeout);
 Transaction tx = startTx(expiration, TransactionType.LONG);
 txMetricsCollector.histogram("start.long.latency", (int) timer.elapsedMillis());
 return tx;
}

代码示例来源:origin: co.cask.tephra/tephra-core

/**
 * Start a long transaction. Long transactions and do not participate in conflict detection. Also, aborting a long
 * transaction moves it to the invalid list because we assume that its writes cannot be rolled back.
 */
public Transaction startLong() {
 txMetricsCollector.rate("start.long");
 Stopwatch timer = new Stopwatch().start();
 long expiration = getTxExpiration(defaultLongTimeout);
 Transaction tx = startTx(expiration, TransactionType.LONG);
 txMetricsCollector.histogram("start.long.latency", (int) timer.elapsedMillis());
 return tx;
}

相关文章