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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6
7 from metrics import Metric
8 from telemetry.core import camel_case
9 from telemetry.value import list_of_scalar_values
10
11 INTERESTING_METRICS = {
12 'packetsReceived': {
13 'units': 'packets',
14 'description': 'Packets received by the peer connection',
15 },
16 'packetsSent': {
17 'units': 'packets',
18 'description': 'Packets sent by the peer connection',
19 },
20 'googDecodeMs': {
21 'units': 'ms',
22 'description': 'Time spent decoding.',
23 },
24 'googMaxDecodeMs': {
25 'units': 'ms',
26 'description': 'Maximum time spent decoding one frame.',
27 },
28 # TODO(phoglund): Add much more interesting metrics.
29 }
30
31 def SortStatsIntoTimeSeries(report_batches):
32 time_series = {}
33 for report_batch in report_batches:
34 for report in report_batch:
35 for stat_name, value in report.iteritems():
36 if stat_name not in INTERESTING_METRICS:
37 continue
38 time_series.setdefault(stat_name, []).append(float(value))
39
40 return time_series
41
42
43 class WebRtcStatisticsMetric(Metric):
44 """Makes it possible to measure stats from peer connections."""
45
46 def __init__(self):
47 super(WebRtcStatisticsMetric, self).__init__()
48 self._all_reports = None
49
50 def Start(self, page, tab):
51 pass
52
53 def Stop(self, page, tab):
54 """Digs out stats from data populated by the javascript in webrtc_cases."""
55 self._all_reports = tab.EvaluateJavaScript(
56 'JSON.stringify(window.peerConnectionReports)')
57
58 def AddResults(self, tab, results):
59 if not self._all_reports:
phoglund_chromium 2014/10/01 13:17:45 Actually, I ended up not logging or asserting here
60 return
61
62 reports = json.loads(self._all_reports)
63 for i, report in enumerate(reports):
64 time_series = SortStatsIntoTimeSeries(report)
65
66 for stat_name, values in time_series.iteritems():
67 stat_name_underscored = camel_case.ToUnderscore(stat_name)
68 trace_name = 'peer_connection_%d_%s' % (i, stat_name_underscored)
69 results.AddValue(list_of_scalar_values.ListOfScalarValues(
70 results.current_page, trace_name,
71 INTERESTING_METRICS[stat_name]['units'], values,
72 description=INTERESTING_METRICS[stat_name]['description'],
73 important=False))
OLDNEW
« 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