• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 package org.webrtc;
12 
13 /**
14  * Class for holding the native pointer of a histogram. Since there is no way to destroy a
15  * histogram, please don't create unnecessary instances of this object. This class is thread safe.
16  *
17  * Usage example:
18  * private static final Histogram someMetricHistogram =
19  *     Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
20  * someMetricHistogram.addSample(someVariable);
21  */
22 class Histogram {
23   private final long handle;
24 
Histogram(long handle)25   private Histogram(long handle) {
26     this.handle = handle;
27   }
28 
createCounts(String name, int min, int max, int bucketCount)29   static public Histogram createCounts(String name, int min, int max, int bucketCount) {
30     return new Histogram(nativeCreateCounts(name, min, max, bucketCount));
31   }
32 
createEnumeration(String name, int max)33   static public Histogram createEnumeration(String name, int max) {
34     return new Histogram(nativeCreateEnumeration(name, max));
35   }
36 
addSample(int sample)37   public void addSample(int sample) {
38     nativeAddSample(handle, sample);
39   }
40 
nativeCreateCounts(String name, int min, int max, int bucketCount)41   private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
nativeCreateEnumeration(String name, int max)42   private static native long nativeCreateEnumeration(String name, int max);
nativeAddSample(long handle, int sample)43   private static native void nativeAddSample(long handle, int sample);
44 }
45