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
14 class _MSEMeasurement(page_test
.PageTest
):
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 []
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
]],
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."""
40 page_set
= page_sets
.ToughVideoCasesPageSet
44 return 'media.tough_video_cases'
48 class MediaNetworkSimulation(benchmark
.Benchmark
):
49 """Obtains media metrics under different network simulations."""
51 page_set
= page_sets
.MediaCnsCasesPageSet
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."""
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'}
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.
78 tag
= 'chromeOS4kOnly'
79 page_set
= page_sets
.ToughVideoCasesPageSet
81 'story_label_filter': 'is_4k',
82 # Exclude is_50fps test files: crbug/331816
83 'story_label_filter_exclude': 'is_50fps'
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
100 page_set
= page_sets
.ToughVideoCasesPageSet
101 # Exclude is_50fps test files: crbug/331816
102 options
= {'story_label_filter_exclude': 'is_4k,is_50fps'}
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
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'])