| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 """Runs Facebook's JSGameBench benchmark. | 5 """Runs Facebook's JSGameBench benchmark. |
| 6 | 6 |
| 7 As of May 14, 2014, JSGameBench is no longer maintained. See README.md: | 7 As of May 14, 2014, JSGameBench is no longer maintained. See README.md: |
| 8 https://github.com/facebookarchive/jsgamebench | 8 https://github.com/facebookarchive/jsgamebench |
| 9 | 9 |
| 10 The benchmark is kept here for historical purposes but is disabled on the bots. | 10 The benchmark is kept here for historical purposes but is disabled on the bots. |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import os | 13 import os |
| 14 | 14 |
| 15 from telemetry import benchmark | 15 from telemetry import benchmark |
| 16 from telemetry.page import page_measurement | 16 from telemetry.page import page_measurement |
| 17 from telemetry.page import page_set | 17 from telemetry.page import page_set |
| 18 from telemetry.value import scalar |
| 18 | 19 |
| 19 | 20 |
| 20 class _JsgamebenchMeasurement(page_measurement.PageMeasurement): | 21 class _JsgamebenchMeasurement(page_measurement.PageMeasurement): |
| 21 def __init__(self): | 22 def __init__(self): |
| 22 super(_JsgamebenchMeasurement, self).__init__() | 23 super(_JsgamebenchMeasurement, self).__init__() |
| 23 | 24 |
| 24 def MeasurePage(self, page, tab, results): | 25 def MeasurePage(self, page, tab, results): |
| 25 tab.ExecuteJavaScript('UI.call({}, "perftest")') | 26 tab.ExecuteJavaScript('UI.call({}, "perftest")') |
| 26 tab.WaitForJavaScriptExpression( | 27 tab.WaitForJavaScriptExpression( |
| 27 'document.getElementById("perfscore0") != null', 1800) | 28 'document.getElementById("perfscore0") != null', 1800) |
| 28 | 29 |
| 29 js_get_results = 'document.getElementById("perfscore0").innerHTML' | 30 js_get_results = 'document.getElementById("perfscore0").innerHTML' |
| 30 result = int(tab.EvaluateJavaScript(js_get_results)) | 31 result = int(tab.EvaluateJavaScript(js_get_results)) |
| 31 results.Add('Score', 'score (bigger is better)', result) | 32 results.AddValue(scalar.ScalarValue( |
| 33 results.current_page, 'Score', 'score (bigger is better)', result)) |
| 32 | 34 |
| 33 | 35 |
| 34 @benchmark.Disabled | 36 @benchmark.Disabled |
| 35 class Jsgamebench(benchmark.Benchmark): | 37 class Jsgamebench(benchmark.Benchmark): |
| 36 """Counts how many animating sprites can move around on the screen at once.""" | 38 """Counts how many animating sprites can move around on the screen at once.""" |
| 37 test = _JsgamebenchMeasurement | 39 test = _JsgamebenchMeasurement |
| 38 | 40 |
| 39 def CreatePageSet(self, options): | 41 def CreatePageSet(self, options): |
| 40 ps = page_set.PageSet( | 42 ps = page_set.PageSet( |
| 41 archive_data_file='../page_sets/data/jsgamebench.json', | 43 archive_data_file='../page_sets/data/jsgamebench.json', |
| 42 file_path=os.path.dirname(__file__)) | 44 file_path=os.path.dirname(__file__)) |
| 43 ps.AddPageWithDefaultRunNavigate('http://localhost/') | 45 ps.AddPageWithDefaultRunNavigate('http://localhost/') |
| 44 return ps | 46 return ps |
| OLD | NEW |