コード例 #1
0
ファイル: Histogram.java プロジェクト: soundcloud/client_java
 /** Observe the given amount. */
 public void observe(double amt) {
   for (int i = 0; i < upperBounds.length; ++i) {
     // The last bucket is +Inf, so we always increment.
     if (amt <= upperBounds[i]) {
       cumulativeCounts[i].add(1);
       break;
     }
   }
   sum.add(amt);
 }
コード例 #2
0
ファイル: Histogram.java プロジェクト: soundcloud/client_java
 /**
  * Get the value of the Histogram.
  *
  * <p><em>Warning:</em> The definition of {@link Value} is subject to change.
  */
 public Value get() {
   Value v = new Value();
   v.buckets = new double[cumulativeCounts.length];
   double acc = 0;
   for (int i = 0; i < cumulativeCounts.length; ++i) {
     acc += cumulativeCounts[i].sum();
     v.buckets[i] = acc;
   }
   v.sum = sum.sum();
   return v;
 }