Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / tools / perf / measurements / repaint.py
blob07360517b90969cc8f2c7d7d358d90ee73e24a7f
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 measurements import smoothness_controller
6 from telemetry.page import page_test
9 class Repaint(page_test.PageTest):
10 def __init__(self, mode='viewport', width=None, height=None):
11 super(Repaint, self).__init__('RunRepaint', False)
12 self._smoothness_controller = None
13 self._micro_benchmark_id = None
14 self._mode = mode
15 self._width = width
16 self._height = height
18 def CustomizeBrowserOptions(self, options):
19 options.AppendExtraBrowserArgs([
20 '--enable-impl-side-painting',
21 '--enable-threaded-compositing',
22 '--enable-gpu-benchmarking'
25 def WillRunActions(self, page, tab):
26 tab.WaitForDocumentReadyStateToBeComplete()
27 self._smoothness_controller = smoothness_controller.SmoothnessController()
28 self._smoothness_controller.SetUp(page, tab)
29 self._smoothness_controller.Start(tab)
30 # Rasterize only what's visible.
31 tab.ExecuteJavaScript(
32 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
34 args = {}
35 args['mode'] = self._mode
36 if self._width:
37 args['width'] = self._width
38 if self._height:
39 args['height'] = self._height
41 # Enque benchmark
42 tab.ExecuteJavaScript("""
43 window.benchmark_results = {};
44 window.benchmark_results.id =
45 chrome.gpuBenchmarking.runMicroBenchmark(
46 "invalidation_benchmark",
47 function(value) {},
48 """ + str(args) + """
50 """)
52 self._micro_benchmark_id = tab.EvaluateJavaScript(
53 'window.benchmark_results.id')
54 if (not self._micro_benchmark_id):
55 raise page_test.MeasurementFailure(
56 'Failed to schedule invalidation_benchmark.')
58 def DidRunActions(self, page, tab):
59 tab.ExecuteJavaScript("""
60 window.benchmark_results.message_handled =
61 chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
62 """ + str(self._micro_benchmark_id) + """, {
63 "notify_done": true
64 });
65 """)
66 self._smoothness_controller.Stop(tab)
68 def ValidateAndMeasurePage(self, page, tab, results):
69 self._smoothness_controller.AddResults(tab, results)
71 def CleanUpAfterPage(self, _, tab):
72 self._smoothness_controller.CleanUp(tab)