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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations