本文整理匯總了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;
}
}
示例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));
}
}
示例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));
}
}
示例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++]);
}
}