diff options
Diffstat (limited to 'guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java')
-rw-r--r-- | guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java index d591f62..841362a 100644 --- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java +++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/Stopwatch.java @@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit; * doSomething(); * stopwatch.{@link #stop stop}(); // optional * - * long millis = stopwatch.elapsed(MILLISECONDS); + * long millis = stopwatch.{@link #elapsedMillis elapsedMillis}(); * * log.info("that took: " + stopwatch); // formatted string like "12.3 ms" * </pre> @@ -68,7 +68,7 @@ import java.util.concurrent.TimeUnit; * @since 10.0 */ @Beta -@GwtCompatible(emulated = true) +@GwtCompatible(emulated=true) public final class Stopwatch { private final Ticker ticker; private boolean isRunning; @@ -88,7 +88,7 @@ public final class Stopwatch { * source. */ public Stopwatch(Ticker ticker) { - this.ticker = checkNotNull(ticker, "ticker"); + this.ticker = checkNotNull(ticker); } /** @@ -107,8 +107,7 @@ public final class Stopwatch { * @throws IllegalStateException if the stopwatch is already running. */ public Stopwatch start() { - checkState(!isRunning, - "This stopwatch is already running; it cannot be started more than once."); + checkState(!isRunning); isRunning = true; startTick = ticker.read(); return this; @@ -123,8 +122,7 @@ public final class Stopwatch { */ public Stopwatch stop() { long tick = ticker.read(); - checkState(isRunning, - "This stopwatch is already stopped; it cannot be stopped more than once."); + checkState(isRunning); isRunning = false; elapsedNanos += tick - startTick; return this; @@ -153,40 +151,18 @@ public final class Stopwatch { * <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); - } - - /** - * 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. - * - * @deprecated Use {@link Stopwatch#elapsed(TimeUnit)} instead. This method is - * scheduled to be removed in Guava release 16.0. - */ - @Deprecated public long elapsedTime(TimeUnit desiredUnit) { - return elapsed(desiredUnit); + return desiredUnit.convert(elapsedNanos(), NANOSECONDS); } /** * Returns the current elapsed time shown on this stopwatch, expressed * in milliseconds, with any fraction rounded down. This is identical to - * {@code elapsed(TimeUnit.MILLISECONDS)}. - * - * @deprecated Use {@code stopwatch.elapsed(MILLISECONDS)} instead. This - * method is scheduled to be removed in Guava release 16.0. + * {@code elapsedTime(TimeUnit.MILLISECONDS}. */ - @Deprecated public long elapsedMillis() { - return elapsed(MILLISECONDS); + return elapsedTime(MILLISECONDS); } private static TimeUnit chooseUnit(long nanos) { |