Search in sources :

Example 6 with WeightedSnapshot

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

the class WeightedSnapshotTest method calculatesAMeanOfZeroForAnEmptySnapshot.

@Test
public void calculatesAMeanOfZeroForAnEmptySnapshot() throws Exception {
    final Snapshot emptySnapshot = new WeightedSnapshot(WeightedArray(new long[] {}, new double[] {}));
    assertThat(emptySnapshot.getMean()).isZero();
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) Test(org.junit.Test)

Example 7 with WeightedSnapshot

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

the class WeightedSnapshotTest method worksWithUnderestimatedCollections.

@Test
public void worksWithUnderestimatedCollections() throws Exception {
    final List<WeightedSample> items = spy(WeightedArray(new long[] { 5, 1, 2, 3, 4 }, new double[] { 1, 2, 3, 2, 2 }));
    when(items.size()).thenReturn(4, 5);
    final Snapshot other = new WeightedSnapshot(items);
    assertThat(other.getValues()).containsOnly(1, 2, 3, 4, 5);
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSample(io.dropwizard.metrics.WeightedSnapshot.WeightedSample) Test(org.junit.Test)

Example 8 with WeightedSnapshot

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

the class WeightedSnapshotTest method calculatesAMaxOfZeroForAnEmptySnapshot.

@Test
public void calculatesAMaxOfZeroForAnEmptySnapshot() throws Exception {
    final Snapshot emptySnapshot = new WeightedSnapshot(WeightedArray(new long[] {}, new double[] {}));
    assertThat(emptySnapshot.getMax()).isZero();
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) Test(org.junit.Test)

Aggregations

Snapshot (io.dropwizard.metrics.Snapshot)8 WeightedSnapshot (io.dropwizard.metrics.WeightedSnapshot)8 Test (org.junit.Test)8 WeightedSample (io.dropwizard.metrics.WeightedSnapshot.WeightedSample)2