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

Side by Side Diff: tools/perf/metrics/webrtc_stats.py

Issue 2950373002: [Perf] Delete unused WebRTC stats metric (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | 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 import logging
7 import re
8
9 from telemetry.internal.util import camel_case
10 from telemetry.value import list_of_scalar_values
11
12 from metrics import Metric
13
14
15 INTERESTING_METRICS = {
16 'googDecodeMs': {
17 'units': 'ms',
18 'description': 'Time spent decoding.',
19 },
20 'googMaxDecodeMs': {
21 'units': 'ms',
22 'description': 'Maximum time spent decoding one frame.',
23 },
24 'googAvgEncodeMs': {
25 'units': 'ms',
26 'description': 'Average time spent encoding one frame.'
27 },
28 'googRtt': {
29 'units': 'ms',
30 'description': 'Measured round-trip time.',
31 },
32 'googJitterReceived': {
33 'units': 'ms',
34 'description': 'Receive-side jitter in milliseconds.',
35 },
36 'googCaptureJitterMs': {
37 'units': 'ms',
38 'description': 'Capture device (audio/video) jitter.',
39 },
40 'googTargetDelayMs': {
41 'units': 'ms',
42 'description': 'The delay we are targeting.',
43 },
44 'googExpandRate': {
45 'units': '%',
46 'description': 'How much we have NetEQ-expanded the audio (0-100%)',
47 },
48 'googFrameRateReceived': {
49 'units': 'fps',
50 'description': 'Receive-side frames per second (video)',
51 },
52 'googFrameRateSent': {
53 'units': 'fps',
54 'description': 'Send-side frames per second (video)',
55 },
56 # Bandwidth estimation stats.
57 'googAvailableSendBandwidth': {
58 'units': 'bit/s',
59 'description': 'How much send bandwidth we estimate we have.'
60 },
61 'googAvailableReceiveBandwidth': {
62 'units': 'bit/s',
63 'description': 'How much receive bandwidth we estimate we have.'
64 },
65 'googTargetEncBitrate': {
66 'units': 'bit/s',
67 'description': ('The target encoding bitrate we estimate is good to '
68 'aim for given our bandwidth estimates.')
69 },
70 }
71
72
73 def SelectMetrics(particular_metrics):
74 if not particular_metrics:
75 return INTERESTING_METRICS
76
77 # You can only select among the predefined interesting metrics.
78 assert set(particular_metrics).issubset(INTERESTING_METRICS.keys())
79 return {key: value for key, value in INTERESTING_METRICS.iteritems()
80 if key in particular_metrics}
81
82
83 def GetReportKind(report):
84 if 'audioInputLevel' in report or 'audioOutputLevel' in report:
85 return 'audio'
86 if 'googFrameRateSent' in report or 'googFrameRateReceived' in report:
87 return 'video'
88 if 'googAvailableSendBandwidth' in report:
89 return 'bwe'
90
91 logging.debug('Did not recognize report batch: %s.', report.keys())
92
93 # There are other kinds of reports, such as transport types, which we don't
94 # care about here. For these cases just return 'unknown' which will ignore the
95 # report.
96 return 'unknown'
97
98
99 def DistinguishAudioVideoOrBwe(report, stat_name):
100 return GetReportKind(report) + '_' + stat_name
101
102
103 def StripAudioVideoBweDistinction(stat_name):
104 return re.sub('^(audio|video|bwe)_', '', stat_name)
105
106
107 def SortStatsIntoTimeSeries(report_batches, selected_metrics):
108 time_series = {}
109 for report_batch in report_batches:
110 for report in report_batch:
111 for stat_name, value in report.iteritems():
112 if stat_name not in selected_metrics:
113 continue
114 if GetReportKind(report) == 'unknown':
115 continue
116 full_stat_name = DistinguishAudioVideoOrBwe(report, stat_name)
117 time_series.setdefault(full_stat_name, []).append(float(value))
118
119 return time_series
120
121
122 def PrintSpecialMarkerValue(results):
123 results.AddValue(list_of_scalar_values.ListOfScalarValues(
124 results.current_page, 'peer_connection_5_not_logging_more_conns',
125 '', [17], description=('This marker signifies we never log more '
126 'than 5 peer connections'),
127 important=False))
128
129
130 class WebRtcStatisticsMetric(Metric):
131 """Makes it possible to measure stats from peer connections."""
132
133 def __init__(self, particular_metrics=None):
134 super(WebRtcStatisticsMetric, self).__init__()
135 self._all_reports = None
136 self._selected_metrics = SelectMetrics(particular_metrics)
137
138 def Start(self, page, tab):
139 pass
140
141 def Stop(self, page, tab):
142 """Digs out stats from data populated by the javascript in webrtc_cases."""
143 self._all_reports = tab.EvaluateJavaScript(
144 'JSON.stringify(window.peerConnectionReports)')
145
146 def AddResults(self, tab, results):
147 if not self._all_reports:
148 return
149
150 reports = json.loads(self._all_reports)
151 for i, report in enumerate(reports):
152 time_series = SortStatsIntoTimeSeries(report, self._selected_metrics)
153
154 # Only ever show stats for 5 peer connections, or it's going to look
155 # insane in the results.
156 if i > 5:
157 PrintSpecialMarkerValue(results)
158 return
159
160 for stat_name, values in time_series.iteritems():
161 stat_name_underscored = camel_case.ToUnderscore(stat_name)
162 trace_name = 'peer_connection_%d_%s' % (i, stat_name_underscored)
163 general_name = StripAudioVideoBweDistinction(stat_name)
164 results.AddValue(list_of_scalar_values.ListOfScalarValues(
165 results.current_page, trace_name,
166 INTERESTING_METRICS[general_name]['units'], values,
167 description=INTERESTING_METRICS[general_name]['description'],
168 important=False))
OLDNEW
« no previous file with comments | « no previous file | tools/perf/metrics/webrtc_stats_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698