use of io.dropwizard.metrics.Meter in project light-4j by networknt.
the class MeterApproximationTest method controlMeter1MinuteMeanApproximation.
@Test
public void controlMeter1MinuteMeanApproximation() throws Exception {
final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 3, TimeUnit.MINUTES);
assertThat(meter.getOneMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
use of io.dropwizard.metrics.Meter in project light-4j by networknt.
the class MeterApproximationTest method controlMeter5MinuteMeanApproximation.
@Test
public void controlMeter5MinuteMeanApproximation() throws Exception {
final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 13, TimeUnit.MINUTES);
assertThat(meter.getFiveMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
use of io.dropwizard.metrics.Meter in project light-4j by networknt.
the class MeterApproximationTest method controlMeter15MinuteMeanApproximation.
@Test
public void controlMeter15MinuteMeanApproximation() throws Exception {
final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 38, TimeUnit.MINUTES);
assertThat(meter.getFifteenMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
use of io.dropwizard.metrics.Meter in project light-4j by networknt.
the class MeterApproximationTest method simulateMetronome.
private Meter simulateMetronome(long introDelay, TimeUnit introDelayUnit, long duration, TimeUnit durationUnit) {
final ManualClock clock = new ManualClock();
final Meter meter = new Meter(clock);
clock.addNanos(introDelayUnit.toNanos(introDelay));
final long endTick = clock.getTick() + durationUnit.toNanos(duration);
final long marksIntervalInNanos = TimeUnit.MINUTES.toNanos(1) / ratePerMinute;
while (clock.getTick() <= endTick) {
clock.addNanos(marksIntervalInNanos);
meter.mark();
}
return meter;
}
use of io.dropwizard.metrics.Meter in project light-4j by networknt.
the class MetricRegistryTest method accessingAMeterRegistersAndReusesIt.
@Test
public void accessingAMeterRegistersAndReusesIt() throws Exception {
final Meter meter1 = registry.meter(THING);
final Meter meter2 = registry.meter(THING);
assertThat(meter1).isSameAs(meter2);
verify(listener).onMeterAdded(THING, meter1);
}
Aggregations