Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: tools/perf/metrics/media.py

Issue 809393002: Added support for improvement_direction to relevant values, which is propogated to chartjson. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix linter issues Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 improvement_direction
8 from telemetry.value import list_of_scalar_values 9 from telemetry.value import list_of_scalar_values
9 from telemetry.value import scalar 10 from telemetry.value import scalar
10 11
11 12
12 class MediaMetric(Metric): 13 class MediaMetric(Metric):
13 """MediaMetric class injects and calls JS responsible for recording metrics. 14 """MediaMetric class injects and calls JS responsible for recording metrics.
14 15
15 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,
16 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
17 decoded_audio_bytes. 18 decoded_audio_bytes.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Media metrics contain an ID identifying the media element and values: 53 Media metrics contain an ID identifying the media element and values:
53 media_metric = { 54 media_metric = {
54 'id': 'video_1', 55 'id': 'video_1',
55 'metrics': { 56 'metrics': {
56 'time_to_play': 120, 57 'time_to_play': 120,
57 'decoded_bytes': 13233, 58 'decoded_bytes': 13233,
58 ... 59 ...
59 } 60 }
60 } 61 }
61 """ 62 """
62 def AddOneResult(metric, unit): 63 def AddOneResult(metric, unit, direction):
63 if metric in exclude_metrics: 64 if metric in exclude_metrics:
64 return 65 return
65 66
66 metrics = media_metric['metrics'] 67 metrics = media_metric['metrics']
67 for m in metrics: 68 for m in metrics:
68 if m.startswith(metric): 69 if m.startswith(metric):
69 special_label = m[len(metric):] 70 special_label = m[len(metric):]
70 trace_name = '%s.%s%s' % (metric, trace, special_label) 71 trace_name = '%s.%s%s' % (metric, trace, special_label)
71 if isinstance(metrics[m], list): 72 if isinstance(metrics[m], list):
72 results.AddValue(list_of_scalar_values.ListOfScalarValues( 73 results.AddValue(list_of_scalar_values.ListOfScalarValues(
73 results.current_page, trace_name, unit, 74 results.current_page, trace_name, unit,
74 values=[float(v) for v in metrics[m]], 75 values=[float(v) for v in metrics[m]],
75 important=True)) 76 important=True, improvement_direction=direction))
76 else: 77 else:
77 results.AddValue(scalar.ScalarValue( 78 results.AddValue(scalar.ScalarValue(
78 results.current_page, trace_name, unit, value=float(metrics[m]), 79 results.current_page, trace_name, unit, value=float(metrics[m]),
79 important=True)) 80 important=True, improvement_direction=direction))
80 81
81 trace = media_metric['id'] 82 trace = media_metric['id']
82 if not trace: 83 if not trace:
83 logging.error('Metrics ID is missing in results.') 84 logging.error('Metrics ID is missing in results.')
84 return 85 return
85 86
86 if not self._skip_basic_metrics: 87 if not self._skip_basic_metrics:
87 AddOneResult('buffering_time', 'ms') 88 AddOneResult('buffering_time', 'ms', improvement_direction.DOWN)
88 AddOneResult('decoded_audio_bytes', 'bytes') 89 AddOneResult('decoded_audio_bytes', 'bytes', improvement_direction.DOWN)
89 AddOneResult('decoded_video_bytes', 'bytes') 90 AddOneResult('decoded_video_bytes', 'bytes', improvement_direction.DOWN)
90 AddOneResult('decoded_frame_count', 'frames') 91 AddOneResult('decoded_frame_count', 'frames', improvement_direction.DOWN)
91 AddOneResult('dropped_frame_count', 'frames') 92 AddOneResult('dropped_frame_count', 'frames', improvement_direction.DOWN)
92 AddOneResult('time_to_play', 'ms') 93 AddOneResult('time_to_play', 'ms', improvement_direction.DOWN)
93 94
94 AddOneResult('avg_loop_time', 'ms') 95 AddOneResult('avg_loop_time', 'ms', improvement_direction.DOWN)
95 AddOneResult('seek', 'ms') 96 AddOneResult('seek', 'ms', improvement_direction.DOWN)
96 return trace 97 return trace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698