本文整理汇总了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++]);
}
}