OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 telemetry import multi_page_benchmark | 5 from telemetry.core import util |
6 from telemetry import util | 6 from telemetry.page import multi_page_benchmark |
7 | 7 |
8 class JsGameBench(multi_page_benchmark.MultiPageBenchmark): | 8 class JsGameBench(multi_page_benchmark.MultiPageBenchmark): |
9 def MeasurePage(self, _, tab, results): | 9 def MeasurePage(self, _, tab, results): |
10 tab.ExecuteJavaScript('UI.call({}, "perftest")') | 10 tab.ExecuteJavaScript('UI.call({}, "perftest")') |
11 | 11 |
12 js_is_done = 'document.getElementById("perfscore0") != null' | 12 js_is_done = 'document.getElementById("perfscore0") != null' |
13 def _IsDone(): | 13 def _IsDone(): |
14 return bool(tab.EvaluateJavaScript(js_is_done)) | 14 return bool(tab.EvaluateJavaScript(js_is_done)) |
15 util.WaitFor(_IsDone, 1200) | 15 util.WaitFor(_IsDone, 1200) |
16 | 16 |
17 js_get_results = 'document.getElementById("perfscore0").innerHTML' | 17 js_get_results = 'document.getElementById("perfscore0").innerHTML' |
18 result = int(tab.EvaluateJavaScript(js_get_results)) | 18 result = int(tab.EvaluateJavaScript(js_get_results)) |
19 results.Add('Score', 'score (bigger is better)', result) | 19 results.Add('Score', 'score (bigger is better)', result) |
OLD | NEW |