| OLD | NEW | 
|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Impact HTML5 Gaming benchmark. | 5 """Impact HTML5 Gaming benchmark. | 
| 6 | 6 | 
| 7 Tests one very specific use case: smooth running games rendered with the | 7 Tests one very specific use case: smooth running games rendered with the | 
| 8 <canvas> element. The score for the HTML5-Benchmark takes the total time the | 8 <canvas> element. The score for the HTML5-Benchmark takes the total time the | 
| 9 browser spent rendering frames (formula is 1000000/(sqrt(totalTime) + lagTime * | 9 browser spent rendering frames (formula is 1000000/(sqrt(totalTime) + lagTime * | 
| 10 0.1)). The benchmark automatically runs at a reasonable screen size. Final | 10 0.1)). The benchmark automatically runs at a reasonable screen size. Final | 
| 11 score is a indicator for the browser's ability to smoothly run HTML5 games.""" | 11 score is a indicator for the browser's ability to smoothly run HTML5 games.""" | 
| 12 | 12 | 
| 13 import os | 13 import os | 
| 14 | 14 | 
| 15 from telemetry import test | 15 from telemetry import test | 
| 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 | 18 | 
| 19 | 19 | 
| 20 class HTML5GamingMeasurement(page_measurement.PageMeasurement): | 20 class _HTML5GamingMeasurement(page_measurement.PageMeasurement): | 
| 21   def MeasurePage(self, _, tab, results): | 21   def MeasurePage(self, _, tab, results): | 
| 22     tab.ExecuteJavaScript('benchmark();') | 22     tab.ExecuteJavaScript('benchmark();') | 
| 23     # Default value of score element is 87485, its value is updated with actual | 23     # Default value of score element is 87485, its value is updated with actual | 
| 24     # score when test finish. | 24     # score when test finish. | 
| 25     tab.WaitForJavaScriptExpression( | 25     tab.WaitForJavaScriptExpression( | 
| 26         'document.getElementById("score").innerHTML != "87485"', 200) | 26         'document.getElementById("score").innerHTML != "87485"', 200) | 
| 27     result = int(tab.EvaluateJavaScript( | 27     result = int(tab.EvaluateJavaScript( | 
| 28         'document.getElementById("score").innerHTML')) | 28         'document.getElementById("score").innerHTML')) | 
| 29     results.Add('Score', 'score', result) | 29     results.Add('Score', 'score', result) | 
| 30 | 30 | 
| 31 | 31 | 
| 32 class HTML5Gaming(test.Test): | 32 class HTML5Gaming(test.Test): | 
| 33   """Imapct HTML5 smooth running games benchmark suite.""" | 33   """Imapct HTML5 smooth running games benchmark suite.""" | 
| 34   test = HTML5GamingMeasurement | 34   test = _HTML5GamingMeasurement | 
| 35   def CreatePageSet(self, options): | 35   def CreatePageSet(self, options): | 
| 36     return page_set.PageSet.FromDict({ | 36     return page_set.PageSet.FromDict({ | 
| 37         'archive_data_file': '../page_sets/data/html5gaming.json', | 37         'archive_data_file': '../page_sets/data/html5gaming.json', | 
| 38         'make_javascript_deterministic': False, | 38         'make_javascript_deterministic': False, | 
| 39         'pages': [ | 39         'pages': [ | 
| 40           { 'url': | 40           { 'url': | 
| 41               'http://html5-benchmark.com/'} | 41               'http://html5-benchmark.com/'} | 
| 42            ] | 42            ] | 
| 43         }, os.path.abspath(__file__)) | 43         }, os.path.abspath(__file__)) | 
| 44 | 44 | 
| OLD | NEW | 
|---|