| 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.page import result_data_type |
| 8 | 9 |
| 9 class MediaMetric(Metric): | 10 class MediaMetric(Metric): |
| 10 """MediaMetric class injects and calls JS responsible for recording metrics. | 11 """MediaMetric class injects and calls JS responsible for recording metrics. |
| 11 | 12 |
| 12 Default media metrics are collected for every media element in the page, | 13 Default media metrics are collected for every media element in the page, |
| 13 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and | 14 such as decoded_frame_count, dropped_frame_count, decoded_video_bytes, and |
| 14 decoded_audio_bytes. | 15 decoded_audio_bytes. |
| 15 """ | 16 """ |
| 16 def __init__(self, tab): | 17 def __init__(self, tab): |
| 17 super(MediaMetric, self).__init__() | 18 super(MediaMetric, self).__init__() |
| (...skipping 27 matching lines...) Expand all Loading... |
| 45 ... | 46 ... |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 """ | 49 """ |
| 49 def AddOneResult(metric, unit): | 50 def AddOneResult(metric, unit): |
| 50 metrics = media_metric['metrics'] | 51 metrics = media_metric['metrics'] |
| 51 for m in metrics: | 52 for m in metrics: |
| 52 if m.startswith(metric): | 53 if m.startswith(metric): |
| 53 special_label = m[len(metric):] | 54 special_label = m[len(metric):] |
| 54 results.Add(trace + special_label, unit, str(metrics[m]), | 55 results.Add(trace + special_label, unit, str(metrics[m]), |
| 55 chart_name=metric, data_type='default') | 56 chart_name=metric, |
| 57 data_type=result_data_type.DEFAULT) |
| 56 | 58 |
| 57 trace = media_metric['id'] | 59 trace = media_metric['id'] |
| 58 if not trace: | 60 if not trace: |
| 59 logging.error('Metrics ID is missing in results.') | 61 logging.error('Metrics ID is missing in results.') |
| 60 return | 62 return |
| 61 AddOneResult('decoded_audio_bytes', 'bytes') | 63 AddOneResult('decoded_audio_bytes', 'bytes') |
| 62 AddOneResult('decoded_video_bytes', 'bytes') | 64 AddOneResult('decoded_video_bytes', 'bytes') |
| 63 AddOneResult('decoded_frame_count', 'frames') | 65 AddOneResult('decoded_frame_count', 'frames') |
| 64 AddOneResult('dropped_frame_count', 'frames') | 66 AddOneResult('dropped_frame_count', 'frames') |
| 65 AddOneResult('playback_time', 'sec') | 67 AddOneResult('playback_time', 'sec') |
| 66 AddOneResult('seek', 'sec') | 68 AddOneResult('seek', 'sec') |
| 67 AddOneResult('time_to_play', 'sec') | 69 AddOneResult('time_to_play', 'sec') |
| 68 | 70 |
| OLD | NEW |