title: how to make histogram of performance numbers
body: <p>I am trying to measure the performance of <code>Database Insert</code>. I have captured all those performance numbers in a <code>ConcurrentHashMap</code>. I am trying to make a Histogram of those numbers.</p>
  
  <p>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.</p>
  
  <pre><code>Key- 11
  Value- 2
  </code></pre>
  
  <p>So that means, 2 Calls came back in 11 ms. Another example below</p>
  
  <pre><code>Key - 30
  Value -1 
  </code></pre>
  
  <p>which means, 1 Call came back in 30 ms.</p>
  
  <p>So basis on the above map, I am trying to do something like this-</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>
  
  <pre><code>private static void logHistogramInfo() {
  
    // here histogram is the concurrenthashmap
      System.out.println(histogram);
  
  
  }
  </code></pre>