[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / benchmarks / media.py
blobeff334562b278a9eb5969ede291f90cb145773ab
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 telemetry import benchmark
6 from telemetry.page import page_test
7 from telemetry.value import list_of_scalar_values
8 from telemetry.value import scalar
10 from measurements import media
11 import page_sets
14 class _MSEMeasurement(page_test.PageTest):
15 def __init__(self):
16 super(_MSEMeasurement, self).__init__()
18 def ValidateAndMeasurePage(self, page, tab, results):
19 media_metric = tab.EvaluateJavaScript('window.__testMetrics')
20 trace = media_metric['id'] if 'id' in media_metric else None
21 metrics = media_metric['metrics'] if 'metrics' in media_metric else []
22 for m in metrics:
23 trace_name = '%s.%s' % (m, trace)
24 if isinstance(metrics[m], list):
25 results.AddValue(list_of_scalar_values.ListOfScalarValues(
26 results.current_page, trace_name, units='ms',
27 values=[float(v) for v in metrics[m]],
28 important=True))
30 else:
31 results.AddValue(scalar.ScalarValue(
32 results.current_page, trace_name, units='ms',
33 value=float(metrics[m]), important=True))
36 @benchmark.Disabled('android') # See media.android.tough_video_cases below
37 class Media(benchmark.Benchmark):
38 """Obtains media metrics for key user scenarios."""
39 test = media.Media
40 page_set = page_sets.ToughVideoCasesPageSet
42 @classmethod
43 def Name(cls):
44 return 'media.tough_video_cases'
47 @benchmark.Disabled
48 class MediaNetworkSimulation(benchmark.Benchmark):
49 """Obtains media metrics under different network simulations."""
50 test = media.Media
51 page_set = page_sets.MediaCnsCasesPageSet
53 @classmethod
54 def Name(cls):
55 return 'media.media_cns_cases'
58 @benchmark.Enabled('android')
59 @benchmark.Disabled('l', 'android-webview') # WebView: crbug.com/419689
60 class MediaAndroid(benchmark.Benchmark):
61 """Obtains media metrics for key user scenarios on Android."""
62 test = media.Media
63 tag = 'android'
64 page_set = page_sets.ToughVideoCasesPageSet
65 # Exclude is_4k and 50 fps media files (garden* & crowd*).
66 options = {'story_label_filter_exclude': 'is_4k,is_50fps'}
68 @classmethod
69 def Name(cls):
70 return 'media.android.tough_video_cases'
73 @benchmark.Enabled('chromeos')
74 class MediaChromeOS4kOnly(benchmark.Benchmark):
75 """Benchmark for media performance on ChromeOS using only is_4k test content.
76 """
77 test = media.Media
78 tag = 'chromeOS4kOnly'
79 page_set = page_sets.ToughVideoCasesPageSet
80 options = {
81 'story_label_filter': 'is_4k',
82 # Exclude is_50fps test files: crbug/331816
83 'story_label_filter_exclude': 'is_50fps'
86 @classmethod
87 def Name(cls):
88 return 'media.chromeOS4kOnly.tough_video_cases'
91 @benchmark.Enabled('chromeos')
92 class MediaChromeOS(benchmark.Benchmark):
93 """Benchmark for media performance on all ChromeOS platforms.
95 This benchmark does not run is_4k content, there's a separate benchmark for
96 that.
97 """
98 test = media.Media
99 tag = 'chromeOS'
100 page_set = page_sets.ToughVideoCasesPageSet
101 # Exclude is_50fps test files: crbug/331816
102 options = {'story_label_filter_exclude': 'is_4k,is_50fps'}
104 @classmethod
105 def Name(cls):
106 return 'media.chromeOS.tough_video_cases'
109 @benchmark.Disabled('android-webview') # crbug.com/419689
110 class MediaSourceExtensions(benchmark.Benchmark):
111 """Obtains media metrics for key media source extensions functions."""
112 test = _MSEMeasurement
113 page_set = page_sets.MseCasesPageSet
115 @classmethod
116 def Name(cls):
117 return 'media.mse_cases'
119 def CustomizeBrowserOptions(self, options):
120 # Needed to allow XHR requests to return stream objects.
121 options.AppendExtraBrowserArgs(
122 ['--enable-experimental-web-platform-features',
123 '--disable-gesture-requirement-for-media-playback'])