MCPcopy
hub / github.com/google/guava / toString

Method toString

guava/src/com/google/common/base/Stopwatch.java:234–243  ·  view source on GitHub ↗

Returns a string representation of the current elapsed time.

()

Source from the content-addressed store, hash-verified

232
233 /** Returns a string representation of the current elapsed time. */
234 @Override
235 public String toString() {
236 long nanos = elapsedNanos();
237
238 TimeUnit unit = chooseUnit(nanos);
239 double value = (double) nanos / NANOSECONDS.convert(1, unit);
240
241 // Too bad this functionality is not exposed as a regular method call
242 return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
243 }
244
245 private static TimeUnit chooseUnit(long nanos) {
246 if (DAYS.convert(nanos, NANOSECONDS) > 0) {

Callers

nothing calls this directly

Calls 5

elapsedNanosMethod · 0.95
chooseUnitMethod · 0.95
formatCompact4DigitsMethod · 0.95
abbreviateMethod · 0.95
convertMethod · 0.45

Tested by

no test coverage detected