/** * Return the duration of the timer in nanoseconds. * * @return The duration of the timer in nanoseconds */ public long getDuration() { if (isRunning()) { LOG.warn("Timer '{}' is still running. Timings may be incorrect.", getName()); } return duration; }
/** * Stop the most recent stopwatch. * * @deprecated Stopping a timer based on context is brittle, and prone to unexpected changes. Timers should be * stopped explicitly, or started in a try-with-resources block */ @Deprecated public static void stopMostRecentTimer() { try { stopTiming(RLOG.get().mostRecentTimer.getName()); } catch (NullPointerException ignored) { LOG.warn("Stopping timing failed because mostRecentTimer wasn't registered."); } }
/** * Registers the final duration of a stopped timer with the RequestLog. * * @param stoppedPhase The phase that has been stopped, and whose duration needs to be stored */ public static void registerTime(TimedPhase stoppedPhase) { RequestLog.REGISTRY.timer(stoppedPhase.getName()).update(stoppedPhase.getDuration(), stoppedPhase.getUnit()); }