Search in sources :

Example 1 with WeightedSnapshot

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

the class WeightedSnapshotTest method calculatesAStdDevOfZeroForASingletonSnapshot.

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

Example 2 with WeightedSnapshot

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

the class WeightedSnapshotTest method calculatesAStdDevOfZeroForAnEmptySnapshot.

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

Example 3 with WeightedSnapshot

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

the class WeightedSnapshotTest method calculatesAMinOfZeroForAnEmptySnapshot.

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

Example 4 with WeightedSnapshot

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

the class WeightedSnapshotTest method expectNoOverflowForLowWeights.

@Test
public void expectNoOverflowForLowWeights() throws Exception {
    final Snapshot scatteredSnapshot = new WeightedSnapshot(WeightedArray(new long[] { 1, 2, 3 }, new double[] { Double.MIN_VALUE, Double.MIN_VALUE, Double.MIN_VALUE }));
    assertThat(scatteredSnapshot.getMean()).isEqualTo(2);
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) Test(org.junit.Test)

Example 5 with WeightedSnapshot

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

the class WeightedSnapshotTest method worksWithOverestimatedCollections.

@Test
public void worksWithOverestimatedCollections() 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(6, 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)

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