OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import time | 5 import time |
6 | 6 |
7 from metrics import smoothness | |
8 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
9 | 8 |
10 class RecordPerArea(page_measurement.PageMeasurement): | 9 class NewRasterizeAndRecord(page_measurement.PageMeasurement): |
11 def __init__(self): | 10 def __init__(self): |
12 super(RecordPerArea, self).__init__('', True) | 11 super(NewRasterizeAndRecord, self).__init__('', True) |
13 | 12 |
14 def AddCommandLineOptions(self, parser): | 13 def AddCommandLineOptions(self, parser): |
15 parser.add_option('--start-wait-time', dest='start_wait_time', | 14 parser.add_option('--start-wait-time', dest='start_wait_time', |
16 default=2, | 15 default=10, |
17 help='Wait time before the benchmark is started ' + | 16 help='Wait time before the benchmark is started ' + |
18 '(must be long enought to load all content)') | 17 '(must be long enought to load all content)') |
19 | 18 |
20 def CustomizeBrowserOptions(self, options): | 19 def CustomizeBrowserOptions(self, options): |
21 smoothness.SmoothnessMetrics.CustomizeBrowserOptions(options) | |
22 options.AppendExtraBrowserArgs([ | 20 options.AppendExtraBrowserArgs([ |
23 '--enable-impl-side-painting', | 21 '--enable-impl-side-painting', |
24 '--force-compositing-mode', | 22 '--force-compositing-mode', |
25 '--enable-threaded-compositing', | 23 '--enable-threaded-compositing', |
26 '--enable-gpu-benchmarking' | 24 '--enable-gpu-benchmarking' |
27 ]) | 25 ]) |
28 | 26 |
29 def MeasurePage(self, page, tab, results): | 27 def MeasurePage(self, page, tab, results): |
30 # Wait until the page has loaded and come to a somewhat steady state. | 28 # 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). | 29 # Needs to be adjusted for every device (~2 seconds for workstation). |
32 time.sleep(float(self.options.start_wait_time)) | 30 time.sleep(float(self.options.start_wait_time)) |
33 | 31 |
34 # Enqueue benchmark | 32 # Enqueue benchmark |
35 tab.ExecuteJavaScript(""" | 33 tab.ExecuteJavaScript(""" |
36 window.benchmark_results = {}; | 34 window.benchmark_results = {}; |
37 window.benchmark_results.done = false; | 35 window.benchmark_results.done = false; |
38 chrome.gpuBenchmarking.runMicroBenchmark( | 36 chrome.gpuBenchmarking.runMicroBenchmark( |
39 "picture_record_benchmark", | 37 "rasterize_and_record_benchmark", |
40 function(value) { | 38 function(value) { |
41 window.benchmark_results.done = true; | 39 window.benchmark_results.done = true; |
42 window.benchmark_results.results = value; | 40 window.benchmark_results.results = value; |
43 }, [{width: 1, height: 1}, | 41 }, { |
44 {width: 250, height: 250}, | 42 "record_repeat_count": 1000, |
45 {width: 500, height: 500}, | 43 "rasterize_repeat_count": 1000 |
46 {width: 750, height: 750}, | 44 }); |
47 {width: 1000, height: 1000}, | |
48 {width: 256, height: 1024}, | |
49 {width: 1024, height: 256}]); | |
50 """) | 45 """) |
51 | 46 |
52 tab.WaitForJavaScriptExpression('window.benchmark_results.done', 300) | 47 tab.WaitForJavaScriptExpression('window.benchmark_results.done', 300) |
53 | 48 |
54 all_data = tab.EvaluateJavaScript('window.benchmark_results.results') | 49 data = tab.EvaluateJavaScript('window.benchmark_results.results') |
55 for data in all_data: | |
56 width = data['width'] | |
57 height = data['height'] | |
58 area = width * height | |
59 time_ms = data['time_ms'] | |
60 | 50 |
61 results.Add('area_%07d_%dx%d' % (area, width, height), 'ms', time_ms) | 51 pixels_recorded = data['pixels_recorded'] |
| 52 record_time = data['record_time_ms'] |
| 53 pixels_rasterized = data['pixels_rasterized'] |
| 54 rasterize_time = data['rasterize_time_ms'] |
62 | 55 |
| 56 results.Add('pixels_recorded', '', pixels_recorded) |
| 57 results.Add('record_time', 'ms', record_time) |
| 58 results.Add('pixels_rasterized', '', pixels_rasterized) |
| 59 results.Add('rasterize_time', 'ms', rasterize_time) |
| 60 |
OLD | NEW |