Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """Media Metrics class injects and calls JS responsible for recording metrics. | 5 """Media Metrics class injects and calls JS responsible for recording metrics. |
| 6 | 6 |
| 7 Default media metrics are collected for every media element in the page, such as | 7 Default media metrics are collected for every media element in the page, such as |
| 8 decoded_frame_count, dropped_frame_count, decoded_video_bytes, and | 8 decoded_frame_count, dropped_frame_count, decoded_video_bytes, and |
| 9 decoded_audio_bytes. | 9 decoded_audio_bytes. |
| 10 """ | 10 """ |
| 11 | 11 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 37 Media metrics contain an ID identifying the media element and values: | 37 Media metrics contain an ID identifying the media element and values: |
| 38 media_metric = { | 38 media_metric = { |
| 39 'id': 'video_1', | 39 'id': 'video_1', |
| 40 'metrics': { | 40 'metrics': { |
| 41 'time_to_play': 120, | 41 'time_to_play': 120, |
| 42 'decoded_bytes': 13233, | 42 'decoded_bytes': 13233, |
| 43 ... | 43 ... |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 """ | 46 """ |
| 47 def AddResult(metric, unit): | 47 def AddResult(metric, unit): |
|
tonyg
2013/07/20 19:57:28
Should this be named AddResults now?
shadi
2013/07/22 19:18:31
Yeah why not :)
| |
| 48 metrics = media_metric['metrics'] | 48 metrics = media_metric['metrics'] |
| 49 if metric in metrics: | 49 for m in metrics: |
| 50 results.Add(trace, unit, str(metrics[metric]), chart_name=metric, | 50 if m.startswith(metric): |
| 51 data_type='default') | 51 special_label = m[len(metric):] |
| 52 results.Add(trace + special_label, unit, str(metrics[m]), | |
| 53 chart_name=metric, data_type='default') | |
| 52 | 54 |
| 53 trace = media_metric['id'] | 55 trace = media_metric['id'] |
| 54 if not trace: | 56 if not trace: |
| 55 logging.error('Metrics ID is missing in results.') | 57 logging.error('Metrics ID is missing in results.') |
| 56 return | 58 return |
| 57 | |
| 58 AddResult('time_to_play', 'sec') | |
| 59 AddResult('playback_time', 'sec') | |
| 60 AddResult('decoded_audio_bytes', 'bytes') | 59 AddResult('decoded_audio_bytes', 'bytes') |
| 61 AddResult('decoded_video_bytes', 'bytes') | 60 AddResult('decoded_video_bytes', 'bytes') |
| 62 AddResult('decoded_frame_count', 'frames') | 61 AddResult('decoded_frame_count', 'frames') |
| 63 AddResult('dropped_frame_count', 'frames') | 62 AddResult('dropped_frame_count', 'frames') |
| 63 AddResult('playback_time', 'sec') | |
| 64 AddResult('seek', 'sec') | |
| 65 AddResult('time_to_play', 'sec') | |
| OLD | NEW |