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

Side by Side Diff: tools/telemetry/telemetry/web_perf/metrics/webrtc_rendering_timeline.py

Issue 1254023003: Telemetry Test for WebRTC Rendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit test to CL Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 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 import logging
5
6 from telemetry.value import list_of_scalar_values
7 from telemetry.value import list_of_string_values
8 from telemetry.value import scalar
9 from telemetry.web_perf.metrics import timeline_based_metric
10 from telemetry.web_perf.metrics import webrtc_rendering_stats as stats_helper
11
12 WEB_MEDIA_PLAYER_MS_EVENT = 'WebMediaPlayerMS::UpdateCurrentFrame'
13
14
15
16 class WebRtcRenderingTimelineMetric(timeline_based_metric.TimelineBasedMetric):
17 """WebrtcRenderingTimelineMetric calculates metric for WebMediaPlayerMS.
18
19 The following metrics are added to the results:
20 WebRtcRendering_drift_time usec
21 WebRTCRendering_std_dev_drift_time usec
22 WebRTCRendering_percent_badly_out_of_sync %
23 WebRTCRendering_percent_out_of_sync %
24 WebRTCRendering_fps FPS
25 WebRTCRendering_smoothness_score %
26 WebRTCRendering_freezing_score %
27 WebRTCRendering_rendering_length_error %
28 """
29
30 def __init__(self):
31 super(WebRtcRenderingTimelineMetric, self).__init__()
32
33 @staticmethod
34 def IsMediaPlayerMSEvent(event):
35 """Verify that the event is a webmediaplayerMS event."""
36 return event.name == WEB_MEDIA_PLAYER_MS_EVENT
37
38 @staticmethod
39 def IsEventInInteraction(event, interaction):
40 """Verify that the event belong to the given interaction."""
41 return interaction[0].start <= event.start <= interaction[0].end
42
43 def AddResults(self, model, renderer_thread, interactions, results):
44 """Adding metrics to the results."""
45 assert interactions
46 found_events = []
47 for event in renderer_thread.parent.IterAllEvents(
48 event_predicate=self.IsMediaPlayerMSEvent):
49 if self.IsEventInInteraction(event, interactions):
50 found_events.append(event)
51 stats_parser = stats_helper.WebMediaPlayerMsRenderingStats(found_events)
52 rendering_stats = stats_parser.GetTimeStats()
53 none_reason = None
54 if not rendering_stats:
55 rendering_stats = dict.fromkeys([
56 'drift_time'
57 'mean_drift_time',
58 'std_dev_drift_time',
59 'percent_badly_out_of_sync',
60 'percent_out_of_sync',
61 'smoothness_score',
62 'freezing_score',
63 'rendering_length_error',
64 'fps',
65 'frame_distribution'])
66 none_reason = "No WebMediaPlayerMS::UpdateCurrentFrame event found"
67 logging.info('rendering stats : %s', rendering_stats)
68 results.AddValue(list_of_scalar_values.ListOfScalarValues(
69 results.current_page,
70 'WebRtcRendering_drift_time',
71 'usec',
72 rendering_stats['drift_time'],
73 important=True,
74 description='Drift time for a rendered frame',
75 none_value_reason=none_reason))
76
77 results.AddValue(scalar.ScalarValue(
78 results.current_page,
79 'WebRTCRendering_mean_drift_time',
80 'usec',
81 rendering_stats['mean_drift_time'],
82 important=True,
83 description='Mean drift time for frames',
84 none_value_reason=none_reason))
85
86 results.AddValue(scalar.ScalarValue(
87 results.current_page,
88 'WebRTCRendering_std_dev_drift_time',
89 'usec',
90 rendering_stats['std_dev_drift_time'],
91 important=True,
92 description='Standard deviation of drift time for frames',
93 none_value_reason=none_reason))
94
95 results.AddValue(scalar.ScalarValue(
96 results.current_page,
97 'WebRTCRendering_percent_badly_out_of_sync',
98 '%',
99 rendering_stats['percent_badly_out_of_sync'],
100 important=True,
101 description='Percentage of frame which drifted more than 2 VSYNC',
102 none_value_reason=none_reason))
103
104 results.AddValue(scalar.ScalarValue(
105 results.current_page,
106 'WebRTCRendering_percent_out_of_sync',
107 '%',
108 rendering_stats['percent_out_of_sync'],
109 important=True,
110 description='Percentage of frame which drifted more than 1 VSYNC',
111 none_value_reason=none_reason))
112
113 # make the output distribution a list since
phoglund_chromium 2015/09/24 07:11:47 Nit: m -> M, end with .
cpaulin (no longer in chrome) 2015/09/24 21:47:38 Done.
114 # no facilities for dict values exist (yet)
115 frame_distribution_list = []
116 for key, value in rendering_stats['frame_distribution'].iteritems():
117 temp = '%s:%s' % (key, value)
118 frame_distribution_list.append(temp)
119 results.AddValue(list_of_string_values.ListOfStringValues(
120 results.current_page,
121 'WebRtcRendering_frame_distribution',
122 'frames:occurences',
123 frame_distribution_list,
124 important=True,
125 description='Output distribution of frames',
126 none_value_reason=none_reason))
127
128 results.AddValue(scalar.ScalarValue(
129 results.current_page,
130 'WebRTCRendering_fps',
131 'FPS',
132 rendering_stats['fps'],
133 important=True,
134 description='Calculated Frame Rate of video rendering',
135 none_value_reason=none_reason))
136
137 results.AddValue(scalar.ScalarValue(
138 results.current_page,
139 'WebRTCRendering_smoothness_score',
140 '%',
141 rendering_stats['smoothness_score'],
142 important=True,
143 description='Smoothness score of rendering',
144 none_value_reason=none_reason))
145
146 results.AddValue(scalar.ScalarValue(
147 results.current_page,
148 'WebRTCRendering_freezing_score',
149 '%',
150 rendering_stats['freezing_score'],
151 important=True,
152 description='Freezing score of rendering',
153 none_value_reason=none_reason))
154
155 results.AddValue(scalar.ScalarValue(
156 results.current_page,
157 'WebRTCRendering_rendering_length_error',
158 '%',
159 rendering_stats['rendering_length_error'],
160 important=True,
161 description='Rendering length error rate',
162 none_value_reason=none_reason))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698