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
16 class _MSEMeasurement(page_test
.PageTest
):
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 []
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
]],
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."""
45 page_set
= page_sets
.ToughVideoCasesPageSet
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."""
56 page_set
= page_sets
.MediaCnsCasesPageSet
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."""
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'}
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.
83 tag
= 'chromeOS4kOnly'
84 page_set
= page_sets
.ToughVideoCasesPageSet
86 'story_label_filter': 'is_4k',
87 # Exclude is_50fps test files: crbug/331816
88 'story_label_filter_exclude': 'is_50fps'
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
105 page_set
= page_sets
.ToughVideoCasesPageSet
106 # Exclude is_50fps test files: crbug/331816
107 options
= {'story_label_filter_exclude': 'is_4k,is_50fps'}
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
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'])