use of org.springside.modules.metrics.metric.TimerMetric in project springside4 by springside.
the class TimerTest method normal.
@Test
public void normal() {
MockClock clock = new MockClock();
Timer.clock = clock;
Counter.clock = clock;
Timer timer = new Timer(new Double[] { 90d });
TimerContext timerContext = timer.start();
clock.increaseTime(200);
timerContext.stop();
TimerContext timer2 = timer.start();
clock.increaseTime(300);
timer2.stop();
TimerMetric metric = timer.calculateMetric();
assertThat(metric.counterMetric.totalCount).isEqualTo(2);
assertThat(metric.counterMetric.avgRate).isEqualTo(4);
assertThat(metric.counterMetric.latestCount).isEqualTo(2);
assertThat(metric.counterMetric.latestRate).isEqualTo(4);
assertThat(metric.histogramMetric.min).isEqualTo(200);
assertThat(metric.histogramMetric.avg).isEqualTo(250);
assertThat(metric.histogramMetric.pcts.get(90d)).isEqualTo(300);
}
Aggregations