/** * Convenience method that returns the {@link #getTimeMonotonic()} value * as a {@link Date} instance. * * @return monotonically increasing time */ public Date getDateMonotonic() { return new Date(getTimeMonotonic()); }
/** * Convenience method that returns the {@link #getTimeMonotonic()} value * as a {@link Date} instance. * * @return monotonically increasing time */ public Date getDateMonotonic() { return new Date(getTimeMonotonic()); }
private static long getTime() { try { return Clock.SIMPLE.getTimeIncreasing(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Clock.SIMPLE.getTimeMonotonic(); } } }
private static long getTime() { try { return Clock.SIMPLE.getTimeIncreasing(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Clock.SIMPLE.getTimeMonotonic(); } } }
/** * starts the clock */ public void start() { clock = new Clock.Fast(executor); start = clock.getTimeMonotonic(); }
/** * starts the clock */ public void start() { clock = new Clock.Fast(executor); start = clock.getTimeMonotonic(); }
/** * convenience method for tracking the messages * * @param customLog a potential custom logger. If null the static instance will be used * @param clock the clock used for tracking. * @param clazz the class to be used during the tracking of times * @param message a custom message for the tracking. */ private static void track(@Nonnull final StopwatchLogger swl, @Nullable final String message) { checkNotNull(swl); if (swl.isEnabled()) { Logger l = swl.getLogger(); if (swl.clock == null) { l.debug("{} - clock has not been started yet.", swl.clazz); } else { Clock c = swl.clock; l.debug( "{} - {} {}ms", new Object[] { checkNotNull(swl.clazz), message == null ? "" : message, c.getTimeMonotonic() - swl.start}); } } }
/** * convenience method for tracking the messages * * @param customLog a potential custom logger. If null the static instance will be used * @param clock the clock used for tracking. * @param clazz the class to be used during the tracking of times * @param message a custom message for the tracking. */ private static void track(@NotNull final StopwatchLogger swl, @Nullable final String message) { checkNotNull(swl); if (swl.isEnabled()) { Logger l = swl.getLogger(); if (swl.clock == null) { l.debug("{} - clock has not been started yet.", swl.clazz); } else { Clock c = swl.clock; l.debug( "{} - {} {}ms", new Object[] { checkNotNull(swl.clazz), message == null ? "" : message, c.getTimeMonotonic() - swl.start}); } } }