當前位置: 首頁>>代碼示例>>Java>>正文


Java Snapshot.getValues方法代碼示例

本文整理匯總了Java中com.codahale.metrics.Snapshot.getValues方法的典型用法代碼示例。如果您正苦於以下問題:Java Snapshot.getValues方法的具體用法?Java Snapshot.getValues怎麽用?Java Snapshot.getValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.codahale.metrics.Snapshot的用法示例。


在下文中一共展示了Snapshot.getValues方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CodahaleSummaryData

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private CodahaleSummaryData(final long count, final Snapshot snapshot) {
  this.count = count;
  this.snapshot = snapshot;
  sum = 0;
  for (final long value : snapshot.getValues()) {
    sum += value;
  }
}
 
開發者ID:outbrain,項目名稱:prometheus-client,代碼行數:9,代碼來源:Summary.java

示例2: reportTimer

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportTimer(String key, Collection<MetricDatum> data, Map.Entry<String, Timer> met) {
    Timer timer = met.getValue();
    Snapshot snapshot = timer.getSnapshot();
    if (reportAggregates) {
        reportAggregate(key, data, "count", null, timer.getCount());
        reportAggregate(key, data, "rate", "1minute", timer.getOneMinuteRate());
        reportAggregate(key, data, "rate", "5minute", timer.getFiveMinuteRate());
        reportAggregate(key, data, "rate", "15minute", timer.getFifteenMinuteRate());
        reportAggregate(key, data, "rate", "mean", timer.getMeanRate());
        reportSnapshot(data, snapshot, key);
    } else {
        // if no data, don't bother Amazon with it.
        if (snapshot.size() == 0) {
            return;
        }
        double sum = 0;
        for (double val : snapshot.getValues()) {
            sum += val;
        }
        // Metrics works in Nanoseconds, which is not one of Amazon's favorites.
        double max = (double) TimeUnit.NANOSECONDS.toMicros(snapshot.getMax());
        double min = (double) TimeUnit.NANOSECONDS.toMicros(snapshot.getMin());
        double sumMicros = TimeUnit.NANOSECONDS.toMicros((long) sum);
        StatisticSet stats = new StatisticSet()
                .withMaximum(max)
                .withMinimum(min)
                .withSum(sumMicros)
                .withSampleCount((double) snapshot.getValues().length);
        if (LOG.isDebugEnabled()) {
            LOG.debug("timer {}: {}", met.getKey(), stats);
        }
        data.add(new MetricDatum().withMetricName(met.getKey())
                .withDimensions(dimensions)
                .withStatisticValues(stats)
                .withUnit(StandardUnit.Microseconds));
    }
}
 
開發者ID:basis-technology-corp,項目名稱:metrics-cloudwatch-reporter,代碼行數:38,代碼來源:CloudWatchReporter.java

示例3: reportHistogram

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistogram(Collection<MetricDatum> data, Map.Entry<String, Histogram> meh) {
    Snapshot snapshot = meh.getValue().getSnapshot();

    if (reportAggregates) {
        String key = meh.getKey();
        reportSnapshot(data, snapshot, key);
    } else {
        // if no data, don't bother Amazon with it.
        if (snapshot.size() == 0) {
            return;
        }
        double sum = 0;
        for (double val : snapshot.getValues()) {
            sum += val;
        }
        StatisticSet stats = new StatisticSet().withMaximum((double) snapshot.getMax())
                .withMinimum((double) snapshot.getMin())
                .withSum(sum)
                .withSampleCount((double) snapshot.getValues().length);
        if (LOG.isDebugEnabled()) {
            LOG.debug("histogram {}: {}", meh.getKey(), stats);
        }
        data.add(new MetricDatum().withMetricName(meh.getKey())
                .withDimensions(dimensions)
                .withStatisticValues(stats));
    }
}
 
開發者ID:basis-technology-corp,項目名稱:metrics-cloudwatch-reporter,代碼行數:28,代碼來源:CloudWatchReporter.java

示例4: testFullSnapshotCalculation

import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
@Test
public void testFullSnapshotCalculation() {
    Reservoir reservoir = new HdrBuilder().withoutSnapshotOptimization().buildReservoir();
    Snapshot snapshot = snapshotTaker.apply(reservoir);

    Histogram hdrHistogram = createEquivalentHistogram();
    assertEquals(hdrHistogram.getStdDeviation(), snapshot.getStdDev());
    assertEquals(hdrHistogram.getMinValue(), snapshot.getMin());
    assertEquals(hdrHistogram.getMean(), snapshot.getMean());
    assertEquals(hdrHistogram.getValueAtPercentile(50.0), (long) snapshot.getMedian());
    assertEquals(hdrHistogram.getMaxValue(), snapshot.getMax());
    assertEquals(hdrHistogram.getValueAtPercentile(60.0), (long) snapshot.getValue(0.6));
    assertEquals(hdrHistogram.getValueAtPercentile(75.0), (long) snapshot.get75thPercentile());
    assertEquals(hdrHistogram.getValueAtPercentile(80.0), (long) snapshot.getValue(0.8));
    assertEquals(hdrHistogram.getValueAtPercentile(90.0), (long) snapshot.getValue(0.9));
    assertEquals(hdrHistogram.getValueAtPercentile(94.0), (long) snapshot.getValue(0.94));
    assertEquals(hdrHistogram.getValueAtPercentile(95.0), (long) snapshot.get95thPercentile());
    assertEquals(hdrHistogram.getValueAtPercentile(98.0), (long) snapshot.get98thPercentile());
    assertEquals(hdrHistogram.getValueAtPercentile(99.0), (long) snapshot.get99thPercentile());
    assertEquals(hdrHistogram.getValueAtPercentile(99.9), (long) snapshot.get999thPercentile());

    assertEquals(hdrHistogram.getTotalCount(), snapshot.size());

    int i = 0;
    long[] values = snapshot.getValues();
    for (HistogramIterationValue value : hdrHistogram.recordedValues()) {
        assertEquals(value.getValueIteratedTo(), values[i++]);
    }
}
 
開發者ID:vladimir-bukhtoyarov,項目名稱:rolling-metrics,代碼行數:30,代碼來源:PercentileCalculationTest.java


注:本文中的com.codahale.metrics.Snapshot.getValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。