1 # Copyright 2013 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.
7 from metrics
import smoothness
8 from telemetry
.page
import page_measurement
10 class RecordPerArea(page_measurement
.PageMeasurement
):
12 super(RecordPerArea
, self
).__init
__('', True)
14 def AddCommandLineOptions(self
, parser
):
15 parser
.add_option('--start-wait-time', dest
='start_wait_time',
17 help='Wait time before the benchmark is started ' +
18 '(must be long enought to load all content)')
20 def CustomizeBrowserOptions(self
, options
):
21 smoothness
.SmoothnessMetrics
.CustomizeBrowserOptions(options
)
22 options
.AppendExtraBrowserArgs([
23 '--enable-impl-side-painting',
24 '--force-compositing-mode',
25 '--enable-threaded-compositing',
26 '--enable-gpu-benchmarking'
29 def MeasurePage(self
, page
, tab
, results
):
30 # Wait until the page has loaded and come to a somewhat steady state.
31 # Needs to be adjusted for every device (~2 seconds for workstation).
32 time
.sleep(float(self
.options
.start_wait_time
))
35 tab
.ExecuteJavaScript("""
36 window.benchmark_results = {};
37 window.benchmark_results.done = false;
38 chrome.gpuBenchmarking.runMicroBenchmark(
39 "picture_record_benchmark",
41 window.benchmark_results.done = true;
42 window.benchmark_results.results = value;
43 }, [{width: 1, height: 1},
44 {width: 250, height: 250},
45 {width: 500, height: 500},
46 {width: 750, height: 750},
47 {width: 1000, height: 1000},
48 {width: 256, height: 1024},
49 {width: 1024, height: 256}]);
52 tab
.WaitForJavaScriptExpression('window.benchmark_results.done', 300)
54 all_data
= tab
.EvaluateJavaScript('window.benchmark_results.results')
57 height
= data
['height']
59 time_ms
= data
['time_ms']
61 results
.Add('area_%07d_%dx%d' % (area
, width
, height
), 'ms', time_ms
)