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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Media Metrics class injects and calls JS responsible for recording metrics.
6
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
9 decoded_audio_bytes.
10 """
11
12 import logging
13 import os
14
15
16 class MediaMetrics(object):
17 def __init__(self, tab):
18 with open(
19 os.path.join(os.path.dirname(__file__), 'media_metrics.js')) as f:
20 js = f.read()
21 tab.ExecuteJavaScript(js)
22 self.tab = tab
23
24 def Start(self):
25 """Create the media metrics for all media elements in the document."""
26 self.tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()')
27
28 def StopAndGetResults(self, results):
29 """Reports all recorded metrics as Telemetry perf results."""
30 media_metrics = self.tab.EvaluateJavaScript('window.__getAllMetrics()')
31 for media_metric in media_metrics:
32 self.AddResultForMediaElement(media_metric, results)
33
34 def AddResultForMediaElement(self, media_metric, results):
35 """Reports metrics for one media element.
36
37 Media metrics contain an ID identifying the media element and values:
38 media_metric = {
39 'id': 'video_1',
40 'metrics': {
41 'time_to_play': 120,
42 'decoded_bytes': 13233,
43 ...
44 }
45 }
46 """
47 def AddResult(metric, unit):
48 metrics = media_metric['metrics']
49 if metric in metrics:
50 results.Add(trace, unit, str(metrics[metric]), chart_name=metric,
51 data_type='default')
52
53 trace = media_metric['id']
54 if not trace:
55 logging.error('Metrics ID is missing in results.')
56 return
57
58 AddResult('time_to_play', 'sec')
59 AddResult('playback_time', 'sec')
60 AddResult('decoded_audio_bytes', 'bytes')
61 AddResult('decoded_video_bytes', 'bytes')
62 AddResult('decoded_frame_count', 'frames')
63 AddResult('dropped_frame_count', 'frames')
OLDNEW
« 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