blob: 5148084431ecee9e40dac19a59a35167b9050192 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
class SmoothnessMetrics(object):
def __init__(self, tab):
self._tab = tab
with open(
os.path.join(os.path.dirname(__file__),
'smoothness_metrics.js')) as f:
js = f.read()
tab.ExecuteJavaScript(js)
def Start(self):
self._tab.ExecuteJavaScript(
'window.__renderingStats = new __RenderingStats();'
'window.__renderingStats.start()')
def SetNeedsDisplayOnAllLayersAndStart(self):
self._tab.ExecuteJavaScript(
'chrome.gpuBenchmarking.setNeedsDisplayOnAllLayers();'
'window.__renderingStats = new __RenderingStats();'
'window.__renderingStats.start()')
def Stop(self):
self._tab.ExecuteJavaScript('window.__renderingStats.stop()')
def BindToAction(self, action):
# Make the scroll test start and stop measurement automatically.
self._tab.ExecuteJavaScript(
'window.__renderingStats = new __RenderingStats();')
action.BindMeasurementJavaScript(self._tab,
'window.__renderingStats.start();',
'window.__renderingStats.stop();')
@property
def start_values(self):
return self._tab.EvaluateJavaScript(
'window.__renderingStats.getStartValues()')
@property
def end_values(self):
return self._tab.EvaluateJavaScript(
'window.__renderingStats.getEndValues()')
@property
def deltas(self):
return self._tab.EvaluateJavaScript(
'window.__renderingStats.getDeltas()')
|