我正在使用LatencyUtils包来跟踪和报告跨度量的延迟行为:
为了通过这种方法记录时间,时间单位应为纳秒,但在我的情况下,记录的时间为毫秒。我想知道是否有更好的方法来记录毫秒时间?
我现在使用的解决方案是将所有记录的时间乘以一百万。但是我仍然希望结果以微秒为单位,因此对于我得到的结果,我将其除以一百万。
public void addValue(Long val, long sampleCount) {
sum += val * sampleCount;
for (int i = 0; i < sampleCount; i++) {
latencyStats.recordLatency(val*1000000);
}
histogram.add(latencyStats.getIntervalHistogram());
max = Math.max(val, max);
min = Math.min(val, min);
updateValueCount(val,sampleCount);
}
@Override
public double getStandardDeviation() {
return histogram.getStdDeviation()/1000000;
}
Run Code Online (Sandbox Code Playgroud)
的默认构造函数LatencyUtil是这样的:
private long lowestTrackableLatency = 1000L; /* 1 usec */
private long highestTrackableLatency = 3600000000000L; /* 1 hr */
private int numberOfSignificantValueDigits = 2;
private int intervalEstimatorWindowLength = 1024;
private long …Run Code Online (Sandbox Code Playgroud)