我正在使用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>
答案 0 :(得分:0)
这是正确的行为。使用指定分辨率/分离的5个小数点(在您的示例中),任何1000000 +/- 100的结果都是正确的。 1000003完全在该范围内,而histogram.valuesAreEquivalent(1000000,1000003)将/应该返回true。 请注意,您可以使用histogram.lowestEquivalentValue(1000000)和 直方图。 highestEquivalentValue(1000000)用于建立等效值的范围。