Search in sources :

Example 1 with UniformReservoir

use of io.dropwizard.metrics.UniformReservoir in project light-4j by networknt.

the class UniformReservoirTest method aReservoirOf100OutOf1000Elements.

@Test
@SuppressWarnings("unchecked")
public void aReservoirOf100OutOf1000Elements() throws Exception {
    final UniformReservoir reservoir = new UniformReservoir(100);
    for (int i = 0; i < 1000; i++) {
        reservoir.update(i);
    }
    final Snapshot snapshot = reservoir.getSnapshot();
    assertThat(reservoir.size()).isEqualTo(100);
    assertThat(snapshot.size()).isEqualTo(100);
    for (double i : snapshot.getValues()) {
        assertThat(i).isLessThan(1000).isGreaterThanOrEqualTo(0);
    }
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) UniformReservoir(io.dropwizard.metrics.UniformReservoir) Test(org.junit.Test)

Aggregations

Snapshot (io.dropwizard.metrics.Snapshot)1 UniformReservoir (io.dropwizard.metrics.UniformReservoir)1 Test (org.junit.Test)1