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 @benchmark.Disabled('android', # See media.android.tough_video_cases below
39 'xp') # crbug.com/475191
40 class Media(perf_benchmark
.PerfBenchmark
):
41 """Obtains media metrics for key user scenarios."""
43 page_set
= page_sets
.ToughVideoCasesPageSet
47 return 'media.tough_video_cases'
50 @benchmark.Disabled('android', 'mac', 'xp')
51 class MediaNetworkSimulation(perf_benchmark
.PerfBenchmark
):
52 """Obtains media metrics under different network simulations."""
54 page_set
= page_sets
.MediaCnsCasesPageSet
58 return 'media.media_cns_cases'
61 @benchmark.Disabled() # crbug.com/448092
62 @benchmark.Disabled('l', 'android-webview') # WebView: crbug.com/419689
63 class MediaAndroid(perf_benchmark
.PerfBenchmark
):
64 """Obtains media metrics for key user scenarios on Android."""
67 page_set
= page_sets
.ToughVideoCasesPageSet
68 # Exclude is_4k and 50 fps media files (garden* & crowd*).
69 options
= {'story_label_filter_exclude': 'is_4k,is_50fps'}
73 return 'media.android.tough_video_cases'
76 @benchmark.Enabled('chromeos')
77 class MediaChromeOS4kOnly(perf_benchmark
.PerfBenchmark
):
78 """Benchmark for media performance on ChromeOS using only is_4k test content.
81 tag
= 'chromeOS4kOnly'
82 page_set
= page_sets
.ToughVideoCasesPageSet
84 'story_label_filter': 'is_4k',
85 # Exclude is_50fps test files: crbug/331816
86 'story_label_filter_exclude': 'is_50fps'
91 return 'media.chromeOS4kOnly.tough_video_cases'
94 @benchmark.Enabled('chromeos')
95 class MediaChromeOS(perf_benchmark
.PerfBenchmark
):
96 """Benchmark for media performance on all ChromeOS platforms.
98 This benchmark does not run is_4k content, there's a separate benchmark for
103 page_set
= page_sets
.ToughVideoCasesPageSet
104 # Exclude is_50fps test files: crbug/331816
105 options
= {'story_label_filter_exclude': 'is_4k,is_50fps'}
109 return 'media.chromeOS.tough_video_cases'
112 @benchmark.Disabled('android-webview') # crbug.com/419689
113 class MediaSourceExtensions(perf_benchmark
.PerfBenchmark
):
114 """Obtains media metrics for key media source extensions functions."""
115 test
= _MSEMeasurement
116 page_set
= page_sets
.MseCasesPageSet
120 return 'media.mse_cases'
122 def SetExtraBrowserOptions(self
, options
):
123 # Needed to allow XHR requests to return stream objects.
124 options
.AppendExtraBrowserArgs(
125 ['--enable-experimental-web-platform-features',
126 '--disable-gesture-requirement-for-media-playback'])