Search in sources :

Example 1 with TimerMetric

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);
}
Also used : TimerMetric(org.springside.modules.metrics.metric.TimerMetric) Timer(org.springside.modules.metrics.metric.Timer) TimerContext(org.springside.modules.metrics.metric.Timer.TimerContext) MockClock(org.springside.modules.metrics.utils.Clock.MockClock) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Timer (org.springside.modules.metrics.metric.Timer)1 TimerContext (org.springside.modules.metrics.metric.Timer.TimerContext)1 TimerMetric (org.springside.modules.metrics.metric.TimerMetric)1 MockClock (org.springside.modules.metrics.utils.Clock.MockClock)1