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 scalar | |
8 from telemetry.value import list_of_scalar_values | |
tonyg
2014/06/11 03:39:39
nit:alphabetize
| |
9 | |
7 from metrics import Metric | 10 from metrics import Metric |
8 | 11 |
9 | 12 |
10 class MediaMetric(Metric): | 13 class MediaMetric(Metric): |
11 """MediaMetric class injects and calls JS responsible for recording metrics. | 14 """MediaMetric class injects and calls JS responsible for recording metrics. |
12 | 15 |
13 Default media metrics are collected for every media element in the page, | 16 Default media metrics are collected for every media element in the page, |
14 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and | 17 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and |
15 decoded_audio_bytes. | 18 decoded_audio_bytes. |
16 """ | 19 """ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 'decoded_bytes': 13233, | 54 'decoded_bytes': 13233, |
52 ... | 55 ... |
53 } | 56 } |
54 } | 57 } |
55 """ | 58 """ |
56 def AddOneResult(metric, unit): | 59 def AddOneResult(metric, unit): |
57 metrics = media_metric['metrics'] | 60 metrics = media_metric['metrics'] |
58 for m in metrics: | 61 for m in metrics: |
59 if m.startswith(metric): | 62 if m.startswith(metric): |
60 special_label = m[len(metric):] | 63 special_label = m[len(metric):] |
64 trace_name = '%s.%s%s' % (metric, trace, special_label) | |
61 if isinstance(metrics[m], list): | 65 if isinstance(metrics[m], list): |
62 values = [float(v) for v in metrics[m]] | 66 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
67 results.current_page, trace_name, unit, | |
68 values=[float(v) for v in metrics[m]], | |
69 important=True)) | |
63 else: | 70 else: |
64 values = float(metrics[m]) | 71 results.AddValue(scalar.ScalarValue( |
65 results.Add(trace + special_label, unit, values, | 72 results.current_page, trace_name, unit, value=float(metrics[m]), |
66 chart_name=metric, data_type='default') | 73 important=True)) |
67 | 74 |
68 trace = media_metric['id'] | 75 trace = media_metric['id'] |
69 if not trace: | 76 if not trace: |
70 logging.error('Metrics ID is missing in results.') | 77 logging.error('Metrics ID is missing in results.') |
71 return | 78 return |
72 | 79 |
73 if not self._skip_basic_metrics: | 80 if not self._skip_basic_metrics: |
74 AddOneResult('buffering_time', 'ms') | 81 AddOneResult('buffering_time', 'ms') |
75 AddOneResult('decoded_audio_bytes', 'bytes') | 82 AddOneResult('decoded_audio_bytes', 'bytes') |
76 AddOneResult('decoded_video_bytes', 'bytes') | 83 AddOneResult('decoded_video_bytes', 'bytes') |
77 AddOneResult('decoded_frame_count', 'frames') | 84 AddOneResult('decoded_frame_count', 'frames') |
78 AddOneResult('dropped_frame_count', 'frames') | 85 AddOneResult('dropped_frame_count', 'frames') |
79 AddOneResult('time_to_play', 'ms') | 86 AddOneResult('time_to_play', 'ms') |
80 | 87 |
81 AddOneResult('avg_loop_time', 'ms') | 88 AddOneResult('avg_loop_time', 'ms') |
82 AddOneResult('seek', 'ms') | 89 AddOneResult('seek', 'ms') |
83 return trace | 90 return trace |
OLD | NEW |