OLD | NEW |
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 import logging | 4 import logging |
5 import os | 5 import os |
6 | 6 |
7 from telemetry.value import list_of_scalar_values | 7 from telemetry.value import list_of_scalar_values |
8 from telemetry.value import scalar | 8 from telemetry.value import scalar |
9 | 9 |
10 from metrics import Metric | 10 from metrics import Metric |
(...skipping 18 matching lines...) Expand all Loading... |
29 def Start(self, page, tab): | 29 def Start(self, page, tab): |
30 """Create the media metrics for all media elements in the document.""" | 30 """Create the media metrics for all media elements in the document.""" |
31 if hasattr(page, 'skip_basic_metrics'): | 31 if hasattr(page, 'skip_basic_metrics'): |
32 self._skip_basic_metrics = page.skip_basic_metrics | 32 self._skip_basic_metrics = page.skip_basic_metrics |
33 tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()') | 33 tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()') |
34 | 34 |
35 def Stop(self, page, tab): | 35 def Stop(self, page, tab): |
36 self._results = tab.EvaluateJavaScript('window.__getAllMetrics()') | 36 self._results = tab.EvaluateJavaScript('window.__getAllMetrics()') |
37 | 37 |
38 # Optional |exclude_metrics| args are not in base class Metric. | 38 # Optional |exclude_metrics| args are not in base class Metric. |
39 # pylint: disable=W0221 | 39 # pylint: disable=arguments-differ |
40 def AddResults(self, tab, results, exclude_metrics=None): | 40 def AddResults(self, tab, results, exclude_metrics=None): |
41 """Reports all recorded metrics as Telemetry perf results.""" | 41 """Reports all recorded metrics as Telemetry perf results.""" |
42 exclude_metrics = exclude_metrics or [] | 42 exclude_metrics = exclude_metrics or [] |
43 trace_names = [] | 43 trace_names = [] |
44 for media_metric in self._results: | 44 for media_metric in self._results: |
45 trace_names.append(self._AddResultsForMediaElement(media_metric, results, | 45 trace_names.append(self._AddResultsForMediaElement(media_metric, results, |
46 exclude_metrics)) | 46 exclude_metrics)) |
47 | 47 |
48 return '_'.join(trace_names) or tab.url | 48 return '_'.join(trace_names) or tab.url |
49 | 49 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 AddOneResult('buffering_time', 'ms') | 88 AddOneResult('buffering_time', 'ms') |
89 AddOneResult('decoded_audio_bytes', 'bytes') | 89 AddOneResult('decoded_audio_bytes', 'bytes') |
90 AddOneResult('decoded_video_bytes', 'bytes') | 90 AddOneResult('decoded_video_bytes', 'bytes') |
91 AddOneResult('decoded_frame_count', 'frames') | 91 AddOneResult('decoded_frame_count', 'frames') |
92 AddOneResult('dropped_frame_count', 'frames') | 92 AddOneResult('dropped_frame_count', 'frames') |
93 AddOneResult('time_to_play', 'ms') | 93 AddOneResult('time_to_play', 'ms') |
94 | 94 |
95 AddOneResult('avg_loop_time', 'ms') | 95 AddOneResult('avg_loop_time', 'ms') |
96 AddOneResult('seek', 'ms') | 96 AddOneResult('seek', 'ms') |
97 return trace | 97 return trace |
OLD | NEW |