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

Unified Diff: tools/perf/perf_tools/media_metrics.py

Issue 16854013: Telemetry media_measurement plus play action and tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove media files (submitted separately) Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/perf_tools/media_metrics.js ('k') | tools/telemetry/telemetry/page/actions/play.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/perf_tools/media_metrics.py
diff --git a/tools/perf/perf_tools/media_metrics.py b/tools/perf/perf_tools/media_metrics.py
new file mode 100644
index 0000000000000000000000000000000000000000..d8b4d09030ee15522e1bb9bf07687c5037307abb
--- /dev/null
+++ b/tools/perf/perf_tools/media_metrics.py
@@ -0,0 +1,63 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Media Metrics class injects and calls JS responsible for recording metrics.
+
+Default media metrics are collected for every media element in the page, such as
+decoded_frame_count, dropped_frame_count, decoded_video_bytes, and
+decoded_audio_bytes.
+"""
+
+import logging
+import os
+
+
+class MediaMetrics(object):
+ def __init__(self, tab):
+ with open(
+ os.path.join(os.path.dirname(__file__), 'media_metrics.js')) as f:
+ js = f.read()
+ tab.ExecuteJavaScript(js)
+ self.tab = tab
+
+ def Start(self):
+ """Create the media metrics for all media elements in the document."""
+ self.tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()')
+
+ def StopAndGetResults(self, results):
+ """Reports all recorded metrics as Telemetry perf results."""
+ media_metrics = self.tab.EvaluateJavaScript('window.__getAllMetrics()')
+ for media_metric in media_metrics:
+ self.AddResultForMediaElement(media_metric, results)
+
+ def AddResultForMediaElement(self, media_metric, results):
+ """Reports metrics for one media element.
+
+ Media metrics contain an ID identifying the media element and values:
+ media_metric = {
+ 'id': 'video_1',
+ 'metrics': {
+ 'time_to_play': 120,
+ 'decoded_bytes': 13233,
+ ...
+ }
+ }
+ """
+ def AddResult(metric, unit):
+ metrics = media_metric['metrics']
+ if metric in metrics:
+ results.Add(trace, unit, str(metrics[metric]), chart_name=metric,
+ data_type='default')
+
+ trace = media_metric['id']
+ if not trace:
+ logging.error('Metrics ID is missing in results.')
+ return
+
+ AddResult('time_to_play', 'sec')
+ AddResult('playback_time', 'sec')
+ AddResult('decoded_audio_bytes', 'bytes')
+ AddResult('decoded_video_bytes', 'bytes')
+ AddResult('decoded_frame_count', 'frames')
+ AddResult('dropped_frame_count', 'frames')
« no previous file with comments | « tools/perf/perf_tools/media_metrics.js ('k') | tools/telemetry/telemetry/page/actions/play.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698