[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / measurements / repaint.py
blobd7e56cb99a2efe4735b50ea0e4cc5441a7525cc5
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.page import page_test
7 from measurements import smoothness_controller
10 class Repaint(page_test.PageTest):
11 def __init__(self, mode='viewport', width=None, height=None):
12 super(Repaint, self).__init__()
13 self._smoothness_controller = None
14 self._micro_benchmark_id = None
15 self._mode = mode
16 self._width = width
17 self._height = height
19 def CustomizeBrowserOptions(self, options):
20 options.AppendExtraBrowserArgs([
21 '--enable-impl-side-painting',
22 '--enable-threaded-compositing',
23 '--enable-gpu-benchmarking'
26 def WillRunActions(self, page, tab):
27 tab.WaitForDocumentReadyStateToBeComplete()
28 self._smoothness_controller = smoothness_controller.SmoothnessController()
29 self._smoothness_controller.SetUp(page, tab)
30 self._smoothness_controller.Start(tab)
31 # Rasterize only what's visible.
32 tab.ExecuteJavaScript(
33 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
35 args = {}
36 args['mode'] = self._mode
37 if self._width:
38 args['width'] = self._width
39 if self._height:
40 args['height'] = self._height
42 # Enque benchmark
43 tab.ExecuteJavaScript("""
44 window.benchmark_results = {};
45 window.benchmark_results.id =
46 chrome.gpuBenchmarking.runMicroBenchmark(
47 "invalidation_benchmark",
48 function(value) {},
49 """ + str(args) + """
51 """)
53 self._micro_benchmark_id = tab.EvaluateJavaScript(
54 'window.benchmark_results.id')
55 if (not self._micro_benchmark_id):
56 raise page_test.MeasurementFailure(
57 'Failed to schedule invalidation_benchmark.')
59 def DidRunActions(self, page, tab):
60 tab.ExecuteJavaScript("""
61 window.benchmark_results.message_handled =
62 chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
63 """ + str(self._micro_benchmark_id) + """, {
64 "notify_done": true
65 });
66 """)
67 self._smoothness_controller.Stop(tab)
69 def ValidateAndMeasurePage(self, page, tab, results):
70 self._smoothness_controller.AddResults(tab, results)
72 def CleanUpAfterPage(self, _, tab):
73 self._smoothness_controller.CleanUp(tab)