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

Unified Diff: tools/perf/metrics/webrtc_stats.py

Issue 561803002: Implements peer connection stats measurements in WebRTC call test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@telemetry
Patch Set: Now tracking peer connections for all webrtc pages. Created 6 years, 3 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
« no previous file with comments | « tools/perf/measurements/webrtc.py ('k') | tools/perf/metrics/webrtc_stats_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/webrtc_stats.py
diff --git a/tools/perf/metrics/webrtc_stats.py b/tools/perf/metrics/webrtc_stats.py
new file mode 100644
index 0000000000000000000000000000000000000000..e96bfcc9d664b279d05d81c3e66ce1d3759833a3
--- /dev/null
+++ b/tools/perf/metrics/webrtc_stats.py
@@ -0,0 +1,73 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+
+from metrics import Metric
+from telemetry.core import camel_case
+from telemetry.value import list_of_scalar_values
+
+INTERESTING_METRICS = {
+ 'packetsReceived': {
+ 'units': 'packets',
+ 'description': 'Packets received by the peer connection',
+ },
+ 'packetsSent': {
+ 'units': 'packets',
+ 'description': 'Packets sent by the peer connection',
+ },
+ 'googDecodeMs': {
+ 'units': 'ms',
+ 'description': 'Time spent decoding.',
+ },
+ 'googMaxDecodeMs': {
+ 'units': 'ms',
+ 'description': 'Maximum time spent decoding one frame.',
+ },
+ # TODO(phoglund): Add much more interesting metrics.
+}
+
+def SortStatsIntoTimeSeries(report_batches):
+ time_series = {}
+ for report_batch in report_batches:
+ for report in report_batch:
+ for stat_name, value in report.iteritems():
+ if stat_name not in INTERESTING_METRICS:
+ continue
+ time_series.setdefault(stat_name, []).append(float(value))
+
+ return time_series
+
+
+class WebRtcStatisticsMetric(Metric):
+ """Makes it possible to measure stats from peer connections."""
+
+ def __init__(self):
+ super(WebRtcStatisticsMetric, self).__init__()
+ self._all_reports = None
+
+ def Start(self, page, tab):
+ pass
+
+ def Stop(self, page, tab):
+ """Digs out stats from data populated by the javascript in webrtc_cases."""
+ self._all_reports = tab.EvaluateJavaScript(
+ 'JSON.stringify(window.peerConnectionReports)')
+
+ def AddResults(self, tab, results):
+ if not self._all_reports:
phoglund_chromium 2014/10/01 13:17:45 Actually, I ended up not logging or asserting here
+ return
+
+ reports = json.loads(self._all_reports)
+ for i, report in enumerate(reports):
+ time_series = SortStatsIntoTimeSeries(report)
+
+ for stat_name, values in time_series.iteritems():
+ stat_name_underscored = camel_case.ToUnderscore(stat_name)
+ trace_name = 'peer_connection_%d_%s' % (i, stat_name_underscored)
+ results.AddValue(list_of_scalar_values.ListOfScalarValues(
+ results.current_page, trace_name,
+ INTERESTING_METRICS[stat_name]['units'], values,
+ description=INTERESTING_METRICS[stat_name]['description'],
+ important=False))
« no previous file with comments | « tools/perf/measurements/webrtc.py ('k') | tools/perf/metrics/webrtc_stats_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698