| 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_test | 6 from telemetry.page import page_test |
| 7 | 7 |
| 8 | 8 |
| 9 class Repaint(page_test.PageTest): | 9 class Repaint(page_test.PageTest): |
| 10 def __init__(self, mode='viewport', width=None, height=None): | 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 | 13 self._micro_benchmark_id = None |
| 14 self._mode = mode | 14 |
| 15 self._width = width | 15 @classmethod |
| 16 self._height = height | 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.') |
| 17 | 27 |
| 18 def CustomizeBrowserOptions(self, options): | 28 def CustomizeBrowserOptions(self, options): |
| 19 options.AppendExtraBrowserArgs([ | 29 options.AppendExtraBrowserArgs([ |
| 20 '--enable-impl-side-painting', | 30 '--enable-impl-side-painting', |
| 21 '--enable-threaded-compositing', | 31 '--enable-threaded-compositing', |
| 22 '--enable-gpu-benchmarking' | 32 '--enable-gpu-benchmarking' |
| 23 ]) | 33 ]) |
| 24 | 34 |
| 25 def WillRunActions(self, page, tab): | 35 def WillRunActions(self, page, tab): |
| 26 tab.WaitForDocumentReadyStateToBeComplete() | 36 tab.WaitForDocumentReadyStateToBeComplete() |
| 27 self._smoothness_controller = smoothness_controller.SmoothnessController() | 37 self._smoothness_controller = smoothness_controller.SmoothnessController() |
| 28 self._smoothness_controller.SetUp(page, tab) | 38 self._smoothness_controller.SetUp(page, tab) |
| 29 self._smoothness_controller.Start(tab) | 39 self._smoothness_controller.Start(tab) |
| 30 # Rasterize only what's visible. | 40 # Rasterize only what's visible. |
| 31 tab.ExecuteJavaScript( | 41 tab.ExecuteJavaScript( |
| 32 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') | 42 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();') |
| 33 | 43 |
| 34 args = {} | 44 args = {} |
| 35 args['mode'] = self._mode | 45 args['mode'] = self.options.mode |
| 36 if self._width: | 46 if self.options.width: |
| 37 args['width'] = self._width | 47 args['width'] = self.options.width |
| 38 if self._height: | 48 if self.options.height: |
| 39 args['height'] = self._height | 49 args['height'] = self.options.height |
| 40 | 50 |
| 41 # Enque benchmark | 51 # Enque benchmark |
| 42 tab.ExecuteJavaScript(""" | 52 tab.ExecuteJavaScript(""" |
| 43 window.benchmark_results = {}; | 53 window.benchmark_results = {}; |
| 44 window.benchmark_results.id = | 54 window.benchmark_results.id = |
| 45 chrome.gpuBenchmarking.runMicroBenchmark( | 55 chrome.gpuBenchmarking.runMicroBenchmark( |
| 46 "invalidation_benchmark", | 56 "invalidation_benchmark", |
| 47 function(value) {}, | 57 function(value) {}, |
| 48 """ + str(args) + """ | 58 """ + str(args) + """ |
| 49 ); | 59 ); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 63 "notify_done": true | 73 "notify_done": true |
| 64 }); | 74 }); |
| 65 """) | 75 """) |
| 66 self._smoothness_controller.Stop(tab) | 76 self._smoothness_controller.Stop(tab) |
| 67 | 77 |
| 68 def ValidateAndMeasurePage(self, page, tab, results): | 78 def ValidateAndMeasurePage(self, page, tab, results): |
| 69 self._smoothness_controller.AddResults(tab, results) | 79 self._smoothness_controller.AddResults(tab, results) |
| 70 | 80 |
| 71 def CleanUpAfterPage(self, _, tab): | 81 def CleanUpAfterPage(self, _, tab): |
| 72 self._smoothness_controller.CleanUp(tab) | 82 self._smoothness_controller.CleanUp(tab) |
| OLD | NEW |