コード例 #1
0
  @Test
  public void calculatesAStdDevOfZeroForASingletonSnapshot() throws Exception {
    final Snapshot singleItemSnapshot =
        new WeightedSnapshot(WeightedArray(new long[] {1}, new double[] {1.0}));

    assertThat(singleItemSnapshot.getStdDev()).isZero();
  }
コード例 #2
0
  @Test
  public void calculatesAStdDevOfZeroForAnEmptySnapshot() throws Exception {
    final Snapshot emptySnapshot =
        new WeightedSnapshot(WeightedArray(new long[] {}, new double[] {}));

    assertThat(emptySnapshot.getStdDev()).isZero();
  }
コード例 #3
0
  private void collectTimerReports(
      List<DBObject> docs, SortedMap<String, Timer> timers, Date timestamp) {
    if (timers.isEmpty()) return;
    for (Map.Entry<String, Timer> entry : timers.entrySet()) {
      final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "timer");
      final Timer v = entry.getValue();
      final Snapshot s = v.getSnapshot();
      // meter part
      report.put("count", v.getCount());
      report.put("rate-unit", getRateUnit());
      report.put("1-minute-rate", convertRate(v.getOneMinuteRate()));
      report.put("5-minute-rate", convertRate(v.getFiveMinuteRate()));
      report.put("15-minute-rate", convertRate(v.getFifteenMinuteRate()));
      report.put("mean-rate", convertRate(v.getMeanRate()));

      // histogram part
      report.put("duration-unit", getDurationUnit());
      report.put("75-percentile", convertDuration(s.get75thPercentile()));
      report.put("95-percentile", convertDuration(s.get95thPercentile()));
      report.put("98-percentile", convertDuration(s.get98thPercentile()));
      report.put("99-percentile", convertDuration(s.get99thPercentile()));
      report.put("999-percentile", convertDuration(s.get999thPercentile()));
      report.put("max", convertDuration(s.getMax()));
      report.put("min", convertDuration(s.getMin()));
      report.put("mean", convertDuration(s.getMean()));
      report.put("median", convertDuration(s.getMedian()));
      report.put("stddev", convertDuration(s.getStdDev()));
      docs.add(report);
    }
  }
コード例 #4
0
  private void collectHistogramReports(
      List<DBObject> docs, SortedMap<String, Histogram> histograms, Date timestamp) {
    if (histograms.isEmpty()) return;

    for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
      final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "histogram");
      final Histogram histogram = entry.getValue();

      final Snapshot s = histogram.getSnapshot();
      report.put("count", s.size());
      report.put("75th_percentile", s.get75thPercentile());
      report.put("95th_percentile", s.get95thPercentile());
      report.put("98th_percentile", s.get98thPercentile());
      report.put("99th_percentile", s.get99thPercentile());
      report.put("999th_percentile", s.get999thPercentile());
      report.put("max", s.getMax());
      report.put("min", s.getMin());
      report.put("mean", s.getMean());
      report.put("median", s.getMedian());
      report.put("std_dev", s.getStdDev());
      docs.add(report);
    }
  }
コード例 #5
0
 @Test
 public void calculatesTheStdDev() throws Exception {
   assertThat(snapshot.getStdDev()).isEqualTo(1.2688, offset(0.0001));
 }