Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1161)

Unified Diff: webrtc/api/java/src/org/webrtc/Histograms.java

Issue 1915523002: Add a default implementation in metrics_default.cc of histograms methods in system_wrappers/interfac (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/api/java/src/org/webrtc/Histograms.java
diff --git a/webrtc/api/java/src/org/webrtc/Histograms.java b/webrtc/api/java/src/org/webrtc/Histograms.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f904e09adb8ca48e5d4f723fe9e9666637cc049
--- /dev/null
+++ b/webrtc/api/java/src/org/webrtc/Histograms.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+package org.webrtc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+// Java-side of androidhistograms_jni.cc (android implementation of methods
+// in webrtc/system_wrappers/interface/metrics.h).
+//
+// The histogram information is stored in a map in androidhistograms_jni.cc.
+// Most histograms are not updated frequently (e.g. most video metrics are an
+// average over the call and recorded when a stream is removed).
+//
+// The histograms can be queried through the API, getAndReset().
+// The returned map holds the name of a histogram and its samples.
+//
+// Example of |map| with one histogram:
+// |name|: "WebRTC.Video.InputFramesPerSecond"
+// |min|: 1
+// |max|: 100
+// |bucketCount|: 50
+// |samples|: [30]:1
+
+public class Histograms {
+ static {
+ System.loadLibrary("jingle_peerconnection_so");
+ }
+ public final Map<String, HistogramInfo> map =
+ new HashMap<String, HistogramInfo>(); // <name, HistogramInfo>
+
+ /**
+ * Class holding histogram information.
+ */
+ public static class HistogramInfo {
+ public final int min;
+ public final int max;
+ public final int bucketCount;
+ public final Map<Integer, Integer> samples =
+ new HashMap<Integer, Integer>(); // <value, # of events>
+
+ public HistogramInfo(int min, int max, int bucketCount) {
+ this.min = min;
+ this.max = max;
+ this.bucketCount = bucketCount;
+ }
+
+ public void addSample(int value, int numEvents) {
+ samples.put(value, numEvents);
+ }
+ }
+
+ public void add(String name, HistogramInfo info) {
+ map.put(name, info);
+ }
+
+ // Enables collection of native histograms.
+ public static void enable() {
+ nativeEnable();
+ }
+
+ // Gets and clears native histograms.
+ public static Histograms getAndReset() {
+ return nativeGetAndReset();
+ }
+
+ private static native void nativeEnable();
+ private static native Histograms nativeGetAndReset();
+}

Powered by Google App Engine
This is Rietveld 408576698