@Override public Stopwatch create() { return createWith(durations, latch::countUp, latch::countDown); }
/** * Create a new {@link Stopwatch} that records all of the measured durations of the stopwatch. * <p> * For example, the following code shows this behavior: * * <pre> * Stopwatch sw = Stopwatch.accumulating(); * sw.start(); * sleep(3000); // sleep 3 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 3 seconds * * sw.start(); * sleep(2000); // sleep 2 seconds * sw.stop(); * print(sw.durations()); // total duration is now 5 seconds, average is 2.5 seconds * </pre> * * @return the new stopwatch; never null */ public static Stopwatch accumulating() { return createWith(new MultipleDurations(), null, null); }
/** * Create a new {@link Stopwatch} that can be reused. The resulting {@link Stopwatch#durations()}, however, * only reflect the most recently completed stopwatch interval. * <p> * For example, the following code shows this behavior: * * <pre> * Stopwatch sw = Stopwatch.reusable(); * sw.start(); * sleep(3000); // sleep 3 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 3 seconds * * sw.start(); * sleep(2000); // sleep 2 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 2 seconds * </pre> * * @return the new stopwatch; never null */ public static Stopwatch reusable() { return createWith(new SingleDuration(), null, null); }
@Override public Stopwatch create() { return createWith(durations, latch::countUp, latch::countDown); }
/** * Create a new {@link Stopwatch} that records all of the measured durations of the stopwatch. * <p> * For example, the following code shows this behavior: * * <pre> * Stopwatch sw = Stopwatch.accumulating(); * sw.start(); * sleep(3000); // sleep 3 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 3 seconds * * sw.start(); * sleep(2000); // sleep 2 seconds * sw.stop(); * print(sw.durations()); // total duration is now 5 seconds, average is 2.5 seconds * </pre> * * @return the new stopwatch; never null */ public static Stopwatch accumulating() { return createWith(new MultipleDurations(), null, null); }
/** * Create a new {@link Stopwatch} that can be reused. The resulting {@link Stopwatch#durations()}, however, * only reflect the most recently completed stopwatch interval. * <p> * For example, the following code shows this behavior: * * <pre> * Stopwatch sw = Stopwatch.reusable(); * sw.start(); * sleep(3000); // sleep 3 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 3 seconds * * sw.start(); * sleep(2000); // sleep 2 seconds * sw.stop(); * print(sw.durations()); // total and average duration are each 2 seconds * </pre> * * @return the new stopwatch; never null */ public static Stopwatch reusable() { return createWith(new SingleDuration(), null, null); }