【问题标题】:Need help in using HdrHistogram java library在使用 HdrHistogram java 库时需要帮助
【发布时间】:2016-04-16 07:44:44
【问题描述】:

我正在使用 HdrHistogram java 库,但没有得到所需的输出。你能帮我理解库或预期值有错误吗?

在这种情况下,我期望输出为 1000000,但实际输出为 1000003

import org.HdrHistogram.*;

public class Main {

public static void main(String[] args) throws InterruptedException {
    Histogram histogram = new Histogram(5);
    histogram.recordValue(1000000);
    histogram.recordValue(1000001);
    histogram.recordValue(1000002);
    histogram.recordValue(90);
    histogram.recordValue(10);

    System.err.println(histogram.getValueAtPercentile(50.0));
}
}

为什么会这样。 我的 Maven 设置是:-

    <dependency>
        <groupId>org.hdrhistogram</groupId>
        <artifactId>HdrHistogram</artifactId>
        <version>2.1.8</version>
    </dependency>

【问题讨论】:

    标签: java histogram hdr date-histogram hdrhistogram


    【解决方案1】:

    这是正确的行为。使用指定分辨率/分隔的 5 个小数点(在您的示例中),任何 1000000 +/- 100 的结果都是正确的。 1000003 正好在该范围内,并且 histogram.valuesAreEquivalent(1000000, 1000003) 将/应该返回 true。 请注意,您可以使用 histogram.lowestEquivalentValue(1000000) 和 直方图。 highEquivalentValue(1000000) 建立等效值的范围。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多