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

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

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

Stopwatch.elapsedNanos介绍

暂无

代码示例

代码示例来源:origin: google/guava

/**
 * Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit,
 * with any fraction rounded down.
 *
 * <p><b>Note:</b> the overhead of measurement can be more than a microsecond, so it is generally
 * not useful to specify {@link TimeUnit#NANOSECONDS} precision here.
 *
 * <p>It is generally not a good idea to use an ambiguous, unitless {@code long} to represent
 * elapsed time. Therefore, we recommend using {@link #elapsed()} instead, which returns a
 * strongly-typed {@link Duration} instance.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: google/j2objc

/**
 * Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit,
 * with any fraction rounded down.
 *
 * <p>Note that the overhead of measurement can be more than a microsecond, so it is generally not
 * useful to specify {@link TimeUnit#NANOSECONDS} precision here.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: thinkaurelius/titan

/**
 * Returns the current elapsed time shown on this stopwatch, expressed
 * in the desired time unit, with any fraction rounded down.
 *
 * <p>Note that the overhead of measurement can be more than a microsecond, so
 * it is generally not useful to specify {@link TimeUnit#NANOSECONDS}
 * precision here.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
  return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: thinkaurelius/titan

@Deprecated
public long elapsedMillis()
{
  return TimeUnit.MILLISECONDS.convert(elapsedNanos(), NANOSECONDS);
}

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

/**
 * Returns the current elapsed time shown on this stopwatch, expressed in the desired time unit,
 * with any fraction rounded down.
 *
 * <p><b>Note:</b> the overhead of measurement can be more than a microsecond, so it is generally
 * not useful to specify {@link TimeUnit#NANOSECONDS} precision here.
 *
 * <p>It is generally not a good idea to use an ambiguous, unitless {@code long} to represent
 * elapsed time. Therefore, we recommend using {@link #elapsed()} instead, which returns a
 * strongly-typed {@link Duration} instance.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: google/guava

/** Returns a string representation of the current elapsed time. */
@Override
public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
}

代码示例来源:origin: google/guava

/**
 * Returns the current elapsed time shown on this stopwatch as a {@link Duration}. Unlike {@link
 * #elapsed(TimeUnit)}, this method does not lose any precision due to rounding.
 *
 * @since 22.0
 */
@GwtIncompatible
@J2ObjCIncompatible
public Duration elapsed() {
 return Duration.ofNanos(elapsedNanos());
}

代码示例来源:origin: thinkaurelius/titan

/**
 * Returns a string representation of the current elapsed time.
 */
@GwtIncompatible("String.format()")
@Override public String toString() {
  long nanos = elapsedNanos();
  TimeUnit unit = chooseUnit(nanos);
  double value = (double) nanos / NANOSECONDS.convert(1, unit);
  // Too bad this functionality is not exposed as a regular method call
  return String.format("%.4g %s", value, abbreviate(unit));
}

代码示例来源:origin: google/j2objc

/** Returns a string representation of the current elapsed time. */
@Override
public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
}

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

/** Returns a string representation of the current elapsed time. */
@Override
public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
}

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

/**
 * Returns the current elapsed time shown on this stopwatch as a {@link Duration}. Unlike {@link
 * #elapsed(TimeUnit)}, this method does not lose any precision due to rounding.
 *
 * @since 22.0
 */
@GwtIncompatible
@J2ObjCIncompatible
public Duration elapsed() {
 return Duration.ofNanos(elapsedNanos());
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns the current elapsed time shown on this stopwatch, expressed
 * in the desired time unit, with any fraction rounded down.
 *
 * <p>Note that the overhead of measurement can be more than a microsecond, so
 * it is generally not useful to specify {@link TimeUnit#NANOSECONDS}
 * precision here.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * Returns the current elapsed time shown on this stopwatch, expressed
 * in the desired time unit, with any fraction rounded down.
 *
 * <p>Note that the overhead of measurement can be more than a microsecond, so
 * it is generally not useful to specify {@link TimeUnit#NANOSECONDS}
 * precision here.
 *
 * @since 14.0 (since 10.0 as {@code elapsedTime()})
 */
public long elapsed(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * Returns the current elapsed time shown on this stopwatch, expressed
 * in the desired time unit, with any fraction rounded down.
 *
 * <p>Note that the overhead of measurement can be more than a microsecond, so
 * it is generally not useful to specify {@link TimeUnit#NANOSECONDS}
 * precision here.
 */
public long elapsedTime(TimeUnit desiredUnit) {
 return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Returns a string representation of the current elapsed time.
 */
@GwtIncompatible("String.format()")
@Override public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return String.format("%.4g %s", value, abbreviate(unit));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Returns a string representation of the current elapsed time.
 */
@GwtIncompatible("String.format()")
@Override public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return String.format("%.4g %s", value, abbreviate(unit));
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Returns a string representation of the current elapsed time.
 */
@GwtIncompatible("String.format()")
@Override public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return String.format("%.4g %s", value, abbreviate(unit));
}

代码示例来源:origin: com.diffplug.guava/guava-core

/**
 * Returns a string representation of the current elapsed time.
 */
@GwtIncompatible("String.format()")
@Override
public String toString() {
  long nanos = elapsedNanos();
  TimeUnit unit = chooseUnit(nanos);
  double value = (double) nanos / NANOSECONDS.convert(1, unit);
  // Too bad this functionality is not exposed as a regular method call
  return String.format(Locale.ROOT, "%.4g %s", value, abbreviate(unit));
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/** Returns a string representation of the current elapsed time. */
@Override
public String toString() {
 long nanos = elapsedNanos();
 TimeUnit unit = chooseUnit(nanos);
 double value = (double) nanos / NANOSECONDS.convert(1, unit);
 // Too bad this functionality is not exposed as a regular method call
 return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Returns the current elapsed time shown on this stopwatch as a {@link Duration}. Unlike {@link
 * #elapsed(TimeUnit)}, this method does not lose any precision due to rounding.
 *
 * @since 22.0
 */
@GwtIncompatible
@J2ObjCIncompatible
public Duration elapsed() {
 return Duration.ofNanos(elapsedNanos());
}

相关文章