/** * Register the given value via {@link MinMaxAvgProbe#register(long)} for the probe of the given {@link StatsType}. * @param statsType the specific execution type that is measured. * @param value the value to register. */ public void register( @Nonnull final StatsType statsType, final long value ) { _probes.get( statsType ).register( value ); }
/** * A utility method that calculates the difference of the time * between the given <code>startInMillis</code> and {@link System#currentTimeMillis()} * and registers the difference via {@link #register(long)}. * @param startInMillis the time in millis that shall be subtracted from {@link System#currentTimeMillis()}. */ public void registerSince( final long startInMillis ) { register( System.currentTimeMillis() - startInMillis ); }
/** * Register the given value via {@link MinMaxAvgProbe#register(long)} for the probe of the given {@link StatsType}. * @param statsType the specific execution type that is measured. * @param value the value to register. */ public void register( @Nonnull final StatsType statsType, final long value ) { _probes.get( statsType ).register( value ); }
/** * A utility method that calculates the difference of the time * between the given <code>startInMillis</code> and {@link System#currentTimeMillis()} * and registers the difference via {@link #register(long)}. * @param startInMillis the time in millis that shall be subtracted from {@link System#currentTimeMillis()}. */ public void registerSince( final long startInMillis ) { register( System.currentTimeMillis() - startInMillis ); }
@Test public void testMinMaxAvgProbe() { final MinMaxAvgProbe cut = new MinMaxAvgProbe(); assertValues( cut, 0, 0, 0, 0 ); cut.register( 1 ); assertValues( cut, 1, 1, 1, 1 ); cut.register( 1 ); assertValues( cut, 2, 1, 1, 1 ); cut.register( 4 ); assertValues( cut, 3, 1, 4, 2 ); cut.register( 0 ); assertValues( cut, 4, 0, 4, 1.5 ); }