Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / perf / benchmarks / media.py
blob424b288c273b9be36891c314a324025995ebd195
1 # Copyright 2014 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.
5 from core import perf_benchmark
7 from telemetry import benchmark
8 from telemetry.page import page_test
9 from telemetry.value import list_of_scalar_values
10 from telemetry.value import scalar
12 from measurements import media
13 import page_sets
16 class _MSEMeasurement(page_test.PageTest):
17 def __init__(self):
18 super(_MSEMeasurement, self).__init__()
20 def ValidateAndMeasurePage(self, page, tab, results):
21 media_metric = tab.EvaluateJavaScript('window.__testMetrics')
22 trace = media_metric['id'] if 'id' in media_metric else None
23 metrics = media_metric['metrics'] if 'metrics' in media_metric else []
24 for m in metrics:
25 trace_name = '%s.%s' % (m, trace)
26 if isinstance(metrics[m], list):
27 results.AddValue(list_of_scalar_values.ListOfScalarValues(
28 results.current_page, trace_name, units='ms',
29 values=[float(v) for v in metrics[m]],
30 important=True))
32 else:
33 results.AddValue(scalar.ScalarValue(
34 results.current_page, trace_name, units='ms',
35 value=float(metrics[m]), important=True))
38 # android: See media.android.tough_video_cases below
39 # xp: crbug.com/475191
40 # win7 & win8: crbug.com/531618
41 @benchmark.Disabled('android', 'xp', 'win7', 'win8')
42 class Media(perf_benchmark.PerfBenchmark):
43 """Obtains media metrics for key user scenarios."""
44 test = media.Media
45 page_set = page_sets.ToughVideoCasesPageSet
47 @classmethod
48 def Name(cls):
49 return 'media.tough_video_cases'
52 @benchmark.Disabled('android', 'mac', 'xp')
53 class MediaNetworkSimulation(perf_benchmark.PerfBenchmark):
54 """Obtains media metrics under different network simulations."""
55 test = media.Media
56 page_set = page_sets.MediaCnsCasesPageSet
58 @classmethod
59 def Name(cls):
60 return 'media.media_cns_cases'
63 @benchmark.Disabled() # crbug.com/448092
64 @benchmark.Disabled('l', 'android-webview') # WebView: crbug.com/419689
65 class MediaAndroid(perf_benchmark.PerfBenchmark):
66 """Obtains media metrics for key user scenarios on Android."""
67 test = media.Media
68 tag = 'android'
69 page_set = page_sets.ToughVideoCasesPageSet
70 # Exclude is_4k and 50 fps media files (garden* & crowd*).
71 options = {'story_label_filter_exclude': 'is_4k,is_50fps'}
73 @classmethod
74 def Name(cls):
75 return 'media.android.tough_video_cases'
78 @benchmark.Enabled('chromeos')
79 class MediaChromeOS4kOnly(perf_benchmark.PerfBenchmark):
80 """Benchmark for media performance on ChromeOS using only is_4k test content.
81 """
82 test = media.Media
83 tag = 'chromeOS4kOnly'
84 page_set = page_sets.ToughVideoCasesPageSet
85 options = {
86 'story_label_filter': 'is_4k',
87 # Exclude is_50fps test files: crbug/331816
88 'story_label_filter_exclude': 'is_50fps'
91 @classmethod
92 def Name(cls):
93 return 'media.chromeOS4kOnly.tough_video_cases'
96 @benchmark.Enabled('chromeos')
97 class MediaChromeOS(perf_benchmark.PerfBenchmark):
98 """Benchmark for media performance on all ChromeOS platforms.
100 This benchmark does not run is_4k content, there's a separate benchmark for
101 that.
103 test = media.Media
104 tag = 'chromeOS'
105 page_set = page_sets.ToughVideoCasesPageSet
106 # Exclude is_50fps test files: crbug/331816
107 options = {'story_label_filter_exclude': 'is_4k,is_50fps'}
109 @classmethod
110 def Name(cls):
111 return 'media.chromeOS.tough_video_cases'
114 @benchmark.Disabled('android-webview') # crbug.com/419689
115 class MediaSourceExtensions(perf_benchmark.PerfBenchmark):
116 """Obtains media metrics for key media source extensions functions."""
117 test = _MSEMeasurement
118 page_set = page_sets.MseCasesPageSet
120 @classmethod
121 def Name(cls):
122 return 'media.mse_cases'
124 def SetExtraBrowserOptions(self, options):
125 # Needed to allow XHR requests to return stream objects.
126 options.AppendExtraBrowserArgs(
127 ['--enable-experimental-web-platform-features',
128 '--disable-gesture-requirement-for-media-playback'])