我正在尝试衡量Database Insert
. 我已经在一个ConcurrentHashMap
. 我正在尝试制作这些数字的直方图。
在那个并发哈希映射中,它将是这样的。我引用了一个例子。但是该地图将有更多的数据意味着更多的键值对。
Key- 11
Value- 2
这意味着,2 个呼叫在 11 毫秒内返回。下面的另一个例子
Key - 30
Value -1
这意味着,1 个呼叫在 30 毫秒内返回。
所以根据上面的地图,我正在尝试做这样的事情 -
Number of calls came back in between 1 and 10 ms
Number of calls came back in between 10 and 20 ms
Number of calls came back in between 20 and 30 ms
Number of calls came back in between 30 and 40 ms
Number of calls came back in between 40 and 50 ms
Number of calls came back in between 50 and 60 ms
Number of calls came back in between 60 and 70 ms
Number of calls came back in between 70 and 80 ms
Number of calls came back in between 80 and 90 ms
Number of calls came back in between 90 and 100 ms
Number of calls came back in greater than 100 ms
我无法找到一种简单的方法来从该地图制作像上面这样的直方图。我能想到的唯一一件事就是对各种计数器进行硬编码,如果它落在该特定范围内,则继续递增这些计数器。但这看起来不是一个干净的方法。任何想法我该如何解决这个问题?
private static void logHistogramInfo() {
// here histogram is the concurrenthashmap
System.out.println(histogram);
}