当前位置: 首页>>代码示例>>Java>>正文


Java MetricsHistogram.update方法代码示例

本文整理汇总了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);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:14,代码来源:TestMetricsHistogram.java

示例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;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:12,代码来源:TestMetricsHistogram.java

示例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());
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:13,代码来源:TestMetricsHistogram.java

示例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);

}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:45,代码来源:TestMetricsHistogram.java


注:本文中的org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。