本文整理汇总了Java中org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram.update方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsHistogram.update方法的具体用法?Java MetricsHistogram.update怎么用?Java MetricsHistogram.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram
的用法示例。
在下文中一共展示了MetricsHistogram.update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasicUniform
import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
@Test
public void testBasicUniform() {
MetricsHistogram h = new MetricsHistogram("testHistogram", null);
for (int i = 0; i < 100; i++) {
h.update(i);
}
Assert.assertEquals(100, h.getCount());
Assert.assertEquals(0, h.getMin());
Assert.assertEquals(99, h.getMax());
Assert.assertEquals(49.5d, h.getMean(), 0.01);
}
示例2: genRandomData
import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
private long[] genRandomData(final MetricsHistogram h) {
final Random r = new Random();
final long[] data = new long[10000];
for (int i = 0; i < data.length; i++) {
data[i] = (long) (r.nextGaussian() * 10000);
h.update(data[i]);
}
return data;
}
示例3: testBasicUniform
import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
@Test
public void testBasicUniform() {
MetricsHistogram h = new MetricsHistogram("testHistogram", null);
for (int i = 0; i < 100; i++) {
h.update(i);
}
Assert.assertEquals(100, h.getCount());
Assert.assertEquals(0, h.getMin());
Assert.assertEquals(99, h.getMax());
}
示例4: testRandom
import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
@Test
public void testRandom() {
final Random r = new Random();
final MetricsHistogram h = new MetricsHistogram("testHistogram", null);
final long[] data = new long[1000];
for (int i = 0; i < data.length; i++) {
data[i] = (long) (r.nextGaussian() * 10000.0);
h.update(data[i]);
}
final Snapshot s = h.getSnapshot();
Arrays.sort(data);
// as long as the histogram chooses an item with index N+/-slop, accept it
final int slop = 20;
// make sure the median, 75th percentile and 95th percentile are good
final int medianIndex = data.length / 2;
final long minAcceptableMedian = data[safeIndex(medianIndex - slop,
data.length)];
final long maxAcceptableMedian = data[safeIndex(medianIndex + slop,
data.length)];
Assert.assertTrue(s.getMedian() >= minAcceptableMedian
&& s.getMedian() <= maxAcceptableMedian);
final int seventyFifthIndex = (int) (data.length * 0.75);
final long minAcceptableseventyFifth = data[safeIndex(seventyFifthIndex
- slop, data.length)];
final long maxAcceptableseventyFifth = data[safeIndex(seventyFifthIndex
+ slop, data.length)];
Assert.assertTrue(s.get75thPercentile() >= minAcceptableseventyFifth
&& s.get75thPercentile() <= maxAcceptableseventyFifth);
final int ninetyFifthIndex = (int) (data.length * 0.95);
final long minAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex
- slop, data.length)];
final long maxAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex
+ slop, data.length)];
Assert.assertTrue(s.get95thPercentile() >= minAcceptableninetyFifth
&& s.get95thPercentile() <= maxAcceptableninetyFifth);
}