OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 from measurements import smoothness_controller | 5 from measurements import smoothness_controller |
6 from telemetry.page import page_measurement | 6 from telemetry.page import page_measurement |
7 | 7 |
8 | 8 |
9 class Repaint(page_measurement.PageMeasurement): | 9 class Repaint(page_measurement.PageMeasurement): |
10 def __init__(self): | 10 def __init__(self): |
11 super(Repaint, self).__init__('RunRepaint', False) | 11 super(Repaint, self).__init__('RunRepaint', False) |
12 self._smoothness_controller = None | 12 self._smoothness_controller = None |
| 13 self._micro_benchmark_id = None |
| 14 |
| 15 @classmethod |
| 16 def AddCommandLineArgs(cls, parser): |
| 17 parser.add_option('--mode', type='string', |
| 18 default='viewport', |
| 19 help='Invalidation mode. ' |
| 20 'Supported values: fixed_size, layer, random, viewport.') |
| 21 parser.add_option('--width', type='int', |
| 22 default=None, |
| 23 help='Width of invalidations for fixed_size mode.') |
| 24 parser.add_option('--height', type='int', |
| 25 default=None, |
| 26 help='Height of invalidations for fixed_size mode.') |
| 27 |
| 28 def CustomizeBrowserOptions(self, options): |
| 29 options.AppendExtraBrowserArgs([ |
| 30 '--enable-impl-side-painting', |
| 31 '--enable-threaded-compositing', |
| 32 '--enable-gpu-benchmarking' |
| 33 ]) |
13 | 34 |
14 def WillRunActions(self, page, tab): | 35 def WillRunActions(self, page, tab): |
15 tab.WaitForDocumentReadyStateToBeComplete() | 36 tab.WaitForDocumentReadyStateToBeComplete() |
16 self._smoothness_controller = smoothness_controller.SmoothnessController() | 37 self._smoothness_controller = smoothness_controller.SmoothnessController() |
17 self._smoothness_controller.Start(page, tab) | 38 self._smoothness_controller.Start(page, tab) |
18 # Rasterize only what's visible. | 39 # Rasterize only what's visible. |
19 tab.ExecuteJavaScript( | 40 tab.ExecuteJavaScript( |
20 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') | 41 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') |
21 | 42 |
| 43 args = {} |
| 44 args['mode'] = self.options.mode |
| 45 if self.options.width: |
| 46 args['width'] = self.options.width |
| 47 if self.options.height: |
| 48 args['height'] = self.options.height |
| 49 |
| 50 # Enque benchmark |
| 51 tab.ExecuteJavaScript(""" |
| 52 window.benchmark_results = {}; |
| 53 window.benchmark_results.id = |
| 54 chrome.gpuBenchmarking.runMicroBenchmark( |
| 55 "invalidation_benchmark", |
| 56 function(value) {}, |
| 57 """ + str(args) + """ |
| 58 ); |
| 59 """) |
| 60 |
| 61 self._micro_benchmark_id = tab.EvaluateJavaScript( |
| 62 'window.benchmark_results.id') |
| 63 if (not self._micro_benchmark_id): |
| 64 raise page_measurement.MeasurementFailure( |
| 65 'Failed to schedule invalidation_benchmark.') |
| 66 |
22 def DidRunActions(self, page, tab): | 67 def DidRunActions(self, page, tab): |
| 68 tab.ExecuteJavaScript(""" |
| 69 window.benchmark_results.message_handled = |
| 70 chrome.gpuBenchmarking.sendMessageToMicroBenchmark( |
| 71 """ + str(self._micro_benchmark_id) + """, { |
| 72 "notify_done": true |
| 73 }); |
| 74 """) |
23 self._smoothness_controller.Stop(tab) | 75 self._smoothness_controller.Stop(tab) |
24 | 76 |
25 def MeasurePage(self, page, tab, results): | 77 def MeasurePage(self, page, tab, results): |
26 self._smoothness_controller.AddResults(tab, results) | 78 self._smoothness_controller.AddResults(tab, results) |
27 | 79 |
28 def CleanUpAfterPage(self, _, tab): | 80 def CleanUpAfterPage(self, _, tab): |
29 self._smoothness_controller.CleanUp(tab) | 81 self._smoothness_controller.CleanUp(tab) |
OLD | NEW |