Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / tools / perf / perf_tools / smoothness_measurement.py
blobc6e6ffbb3f3448f20965f0da258069321d1dd738
1 # Copyright (c) 2012 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.
4 import os
6 class SmoothnessMeasurement(object):
7 def __init__(self, tab):
8 self._tab = tab
9 # Bring in the smoothness benchmark
10 with open(
11 os.path.join(os.path.dirname(__file__),
12 'smoothness_measurement.js')) as f:
13 js = f.read()
14 tab.ExecuteJavaScript(js)
16 def Start(self):
17 self._tab.ExecuteJavaScript(
18 'window.__renderingStats = new __RenderingStats();'
19 'window.__renderingStats.start()')
21 def Stop(self):
22 self._tab.ExecuteJavaScript('window.__renderingStats.stop()')
24 def BindToAction(self, action):
25 # Make the scroll test start and stop measurement automatically.
26 self._tab.ExecuteJavaScript(
27 'window.__renderingStats = new __RenderingStats();')
28 action.BindMeasurementJavaScript(self._tab,
29 'window.__renderingStats.start();',
30 'window.__renderingStats.stop();')
32 @property
33 def start_values(self):
34 return self._tab.EvaluateJavaScript(
35 'window.__renderingStats.getStartValues()')
37 @property
38 def end_values(self):
39 return self._tab.EvaluateJavaScript(
40 'window.__renderingStats.getEndValues()')
42 @property
43 def deltas(self):
44 return self._tab.EvaluateJavaScript(
45 'window.__renderingStats.getDeltas()')