I am trying to measure the performance of Database Insert
. I have captured all those performance numbers in a ConcurrentHashMap
. I am trying to make a Histogram of those numbers.
In that concurrent hash map it will be something like this.I am quoting an example. But that map will have lot more data means lot more key value pair.
Key- 11
Value- 2
So that means, 2 Calls came back in 11 ms. Another example below
Key - 30
Value -1
which means, 1 Call came back in 30 ms.
So basis on the above map, I am trying to do something like this-
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
I am not able to find an easy approach to make a histogram like above from that map. Only thing I can think of is hard code the various counter and keep on incrementing those counter if it falls within that particular range. But this doesn't looks a clean way to do it. Any thoughts how can I solve this problem?
private static void logHistogramInfo() {
// here histogram is the concurrenthashmap
System.out.println(histogram);
}