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

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

Issue 2719853003: [Telemetry refactor] Drop "2" from method calls to JS API (Closed)
Patch Set: Created 3 years, 9 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/metrics/loading.py ('k') | tools/perf/metrics/startup_metric.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 7
8 from telemetry.value import list_of_scalar_values 8 from telemetry.value import list_of_scalar_values
9 from telemetry.value import scalar 9 from telemetry.value import scalar
10 10
11 from metrics import Metric 11 from metrics import Metric
12 12
13 13
14 class MediaMetric(Metric): 14 class MediaMetric(Metric):
15 """MediaMetric class injects and calls JS responsible for recording metrics. 15 """MediaMetric class injects and calls JS responsible for recording metrics.
16 16
17 Default media metrics are collected for every media element in the page, 17 Default media metrics are collected for every media element in the page,
18 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and 18 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and
19 decoded_audio_bytes. 19 decoded_audio_bytes.
20 """ 20 """
21 21
22 def __init__(self, tab): 22 def __init__(self, tab):
23 super(MediaMetric, self).__init__() 23 super(MediaMetric, self).__init__()
24 with open(os.path.join(os.path.dirname(__file__), 'media.js')) as f: 24 with open(os.path.join(os.path.dirname(__file__), 'media.js')) as f:
25 js = f.read() 25 js = f.read()
26 tab.ExecuteJavaScript2(js) 26 tab.ExecuteJavaScript(js)
27 self._results = None 27 self._results = None
28 self._skip_basic_metrics = False 28 self._skip_basic_metrics = False
29 29
30 def Start(self, page, tab): 30 def Start(self, page, tab):
31 """Create the media metrics for all media elements in the document.""" 31 """Create the media metrics for all media elements in the document."""
32 if hasattr(page, 'skip_basic_metrics'): 32 if hasattr(page, 'skip_basic_metrics'):
33 self._skip_basic_metrics = page.skip_basic_metrics 33 self._skip_basic_metrics = page.skip_basic_metrics
34 tab.ExecuteJavaScript2('window.__createMediaMetricsForDocument()') 34 tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()')
35 35
36 def Stop(self, page, tab): 36 def Stop(self, page, tab):
37 self._results = tab.EvaluateJavaScript2('window.__getAllMetrics()') 37 self._results = tab.EvaluateJavaScript('window.__getAllMetrics()')
38 38
39 # Optional |exclude_metrics| args are not in base class Metric. 39 # Optional |exclude_metrics| args are not in base class Metric.
40 # pylint: disable=arguments-differ 40 # pylint: disable=arguments-differ
41 def AddResults(self, tab, results, exclude_metrics=None): 41 def AddResults(self, tab, results, exclude_metrics=None):
42 """Reports all recorded metrics as Telemetry perf results.""" 42 """Reports all recorded metrics as Telemetry perf results."""
43 exclude_metrics = exclude_metrics or [] 43 exclude_metrics = exclude_metrics or []
44 trace_names = [] 44 trace_names = []
45 for media_metric in self._results: 45 for media_metric in self._results:
46 trace_names.append(self._AddResultsForMediaElement(media_metric, results, 46 trace_names.append(self._AddResultsForMediaElement(media_metric, results,
47 exclude_metrics)) 47 exclude_metrics))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 AddOneResult('buffering_time', 'ms') 89 AddOneResult('buffering_time', 'ms')
90 AddOneResult('decoded_audio_bytes', 'bytes') 90 AddOneResult('decoded_audio_bytes', 'bytes')
91 AddOneResult('decoded_video_bytes', 'bytes') 91 AddOneResult('decoded_video_bytes', 'bytes')
92 AddOneResult('decoded_frame_count', 'frames') 92 AddOneResult('decoded_frame_count', 'frames')
93 AddOneResult('dropped_frame_count', 'frames') 93 AddOneResult('dropped_frame_count', 'frames')
94 AddOneResult('time_to_play', 'ms') 94 AddOneResult('time_to_play', 'ms')
95 95
96 AddOneResult('avg_loop_time', 'ms') 96 AddOneResult('avg_loop_time', 'ms')
97 AddOneResult('seek', 'ms') 97 AddOneResult('seek', 'ms')
98 return trace 98 return trace
OLDNEW
« no previous file with comments | « tools/perf/metrics/loading.py ('k') | tools/perf/metrics/startup_metric.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698