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 metrics import Metric | 7 from metrics import Metric |
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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 Media metrics contain an ID identifying the media element and values: | 52 Media metrics contain an ID identifying the media element and values: |
53 media_metric = { | 53 media_metric = { |
54 'id': 'video_1', | 54 'id': 'video_1', |
55 'metrics': { | 55 'metrics': { |
56 'time_to_play': 120, | 56 'time_to_play': 120, |
57 'decoded_bytes': 13233, | 57 'decoded_bytes': 13233, |
58 ... | 58 ... |
59 } | 59 } |
60 } | 60 } |
61 """ | 61 """ |
62 def AddOneResult(metric, unit): | 62 def AddOneResult(metric, unit, higher_is_better): |
63 if metric in exclude_metrics: | 63 if metric in exclude_metrics: |
64 return | 64 return |
65 | 65 |
66 metrics = media_metric['metrics'] | 66 metrics = media_metric['metrics'] |
67 for m in metrics: | 67 for m in metrics: |
68 if m.startswith(metric): | 68 if m.startswith(metric): |
69 special_label = m[len(metric):] | 69 special_label = m[len(metric):] |
70 trace_name = '%s.%s%s' % (metric, trace, special_label) | 70 trace_name = '%s.%s%s' % (metric, trace, special_label) |
71 if isinstance(metrics[m], list): | 71 if isinstance(metrics[m], list): |
72 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 72 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
73 results.current_page, trace_name, unit, | 73 results.current_page, trace_name, unit, |
74 values=[float(v) for v in metrics[m]], | 74 values=[float(v) for v in metrics[m]], |
75 important=True)) | 75 important=True, higher_is_better=higher_is_better)) |
76 else: | 76 else: |
77 results.AddValue(scalar.ScalarValue( | 77 results.AddValue(scalar.ScalarValue( |
78 results.current_page, trace_name, unit, value=float(metrics[m]), | 78 results.current_page, trace_name, unit, value=float(metrics[m]), |
79 important=True)) | 79 important=True, higher_is_better=higher_is_better)) |
80 | 80 |
81 trace = media_metric['id'] | 81 trace = media_metric['id'] |
82 if not trace: | 82 if not trace: |
83 logging.error('Metrics ID is missing in results.') | 83 logging.error('Metrics ID is missing in results.') |
84 return | 84 return |
85 | 85 |
86 if not self._skip_basic_metrics: | 86 if not self._skip_basic_metrics: |
87 AddOneResult('buffering_time', 'ms') | 87 AddOneResult('buffering_time', 'ms', False) |
88 AddOneResult('decoded_audio_bytes', 'bytes') | 88 AddOneResult('decoded_audio_bytes', 'bytes', False) |
89 AddOneResult('decoded_video_bytes', 'bytes') | 89 AddOneResult('decoded_video_bytes', 'bytes', False) |
90 AddOneResult('decoded_frame_count', 'frames') | 90 AddOneResult('decoded_frame_count', 'frames', False) |
91 AddOneResult('dropped_frame_count', 'frames') | 91 AddOneResult('dropped_frame_count', 'frames', False) |
92 AddOneResult('time_to_play', 'ms') | 92 AddOneResult('time_to_play', 'ms', False) |
93 | 93 |
94 AddOneResult('avg_loop_time', 'ms') | 94 AddOneResult('avg_loop_time', 'ms', False) |
95 AddOneResult('seek', 'ms') | 95 AddOneResult('seek', 'ms', False) |
96 return trace | 96 return trace |
OLD | NEW |