use of org.opendaylight.infrautils.metrics.Timer in project infrautils by opendaylight.
the class MetricProviderTest method testTimeCallableWithLabels.
@Test
public void testTimeCallableWithLabels() {
Labeled<Labeled<Timer>> timerWithTwoLabels = metrics.newTimer(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_timer_with_labels").build(), "l1", "l2");
Timer timerA = timerWithTwoLabels.label("l1value").label("l2value");
assertThat(timerA.time(() -> {
@Var int sum = 0;
for (int i = 1; i < 101; i++) {
sum += i;
}
return sum;
})).isEqualTo(5050);
}
use of org.opendaylight.infrautils.metrics.Timer in project infrautils by opendaylight.
the class MetricProviderTest method testTimeRunnableOKWithLabels.
@Test
public void testTimeRunnableOKWithLabels() {
Labeled<Labeled<Timer>> timerWithTwoLabels = metrics.newTimer(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_timer_with_labels").build(), "l1", "l2");
Timer timerA = timerWithTwoLabels.label("l1value").label("l2value");
timerA.time(() -> {
for (@SuppressWarnings("unused") int sum = 0, i = 1; i < 101; i++) {
sum += i;
}
});
}