| 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 """Runs Browsermark CSS, DOM, WebGL, JS, resize and page load benchmarks. | 5 """Runs Browsermark CSS, DOM, WebGL, JS, resize and page load benchmarks. |
| 6 | 6 |
| 7 Browsermark benchmark suite have five test groups: | 7 Browsermark benchmark suite have five test groups: |
| 8 a) CSS group: measures your browsers 2D and 3D performance, and finally executes | 8 a) CSS group: measures your browsers 2D and 3D performance, and finally executes |
| 9 CSS Crunch test | 9 CSS Crunch test |
| 10 b) DOM group: measures variety of areas, like how well your browser traverse in | 10 b) DOM group: measures variety of areas, like how well your browser traverse in |
| 11 Document Object Model Tree or how fast your browser can create dynamic content | 11 Document Object Model Tree or how fast your browser can create dynamic content |
| 12 c) General group: measures areas like resize and page load times | 12 c) General group: measures areas like resize and page load times |
| 13 d) Graphics group: tests browsers Graphics Processing Unit power by measuring | 13 d) Graphics group: tests browsers Graphics Processing Unit power by measuring |
| 14 WebGL and Canvas performance | 14 WebGL and Canvas performance |
| 15 e) Javascript group: executes number crunching by doing selected Array and | 15 e) Javascript group: executes number crunching by doing selected Array and |
| 16 String operations | 16 String operations |
| 17 Additionally Browsermark will test your browsers conformance, but conformance | 17 Additionally Browsermark will test your browsers conformance, but conformance |
| 18 tests are not included in this suite. | 18 tests are not included in this suite. |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 import os | 21 import os |
| 22 | 22 |
| 23 from telemetry import test | 23 from telemetry import benchmark |
| 24 from telemetry.page import page_measurement | 24 from telemetry.page import page_measurement |
| 25 from telemetry.page import page_set | 25 from telemetry.page import page_set |
| 26 | 26 |
| 27 class _BrowsermarkMeasurement(page_measurement.PageMeasurement): | 27 class _BrowsermarkMeasurement(page_measurement.PageMeasurement): |
| 28 | 28 |
| 29 def MeasurePage(self, _, tab, results): | 29 def MeasurePage(self, _, tab, results): |
| 30 # Select nearest server(North America=1) and start test. | 30 # Select nearest server(North America=1) and start test. |
| 31 js_start_test = """ | 31 js_start_test = """ |
| 32 for (var i=0; i < $('#continent a').length; i++) { | 32 for (var i=0; i < $('#continent a').length; i++) { |
| 33 if (($('#continent a')[i]).getAttribute('data-id') == '1') { | 33 if (($('#continent a')[i]).getAttribute('data-id') == '1') { |
| 34 $('#continent a')[i].click(); | 34 $('#continent a')[i].click(); |
| 35 $('.start_test.enabled').click(); | 35 $('.start_test.enabled').click(); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 """ | 38 """ |
| 39 tab.ExecuteJavaScript(js_start_test) | 39 tab.ExecuteJavaScript(js_start_test) |
| 40 tab.WaitForJavaScriptExpression( | 40 tab.WaitForJavaScriptExpression( |
| 41 'window.location.pathname.indexOf("results") != -1', 600) | 41 'window.location.pathname.indexOf("results") != -1', 600) |
| 42 result = int(tab.EvaluateJavaScript( | 42 result = int(tab.EvaluateJavaScript( |
| 43 'document.getElementsByClassName("score")[0].innerHTML')) | 43 'document.getElementsByClassName("score")[0].innerHTML')) |
| 44 results.Add('Score', 'score', result) | 44 results.Add('Score', 'score', result) |
| 45 | 45 |
| 46 | 46 |
| 47 class Browsermark(test.Test): | 47 class Browsermark(benchmark.Benchmark): |
| 48 """Browsermark suite tests CSS, DOM, resize, page load, WebGL and JS.""" | 48 """Browsermark suite tests CSS, DOM, resize, page load, WebGL and JS.""" |
| 49 test = _BrowsermarkMeasurement | 49 test = _BrowsermarkMeasurement |
| 50 def CreatePageSet(self, options): | 50 def CreatePageSet(self, options): |
| 51 ps = page_set.PageSet( | 51 ps = page_set.PageSet( |
| 52 file_path=os.path.abspath(__file__), | 52 file_path=os.path.abspath(__file__), |
| 53 archive_data_file='../page_sets/data/browsermark.json', | 53 archive_data_file='../page_sets/data/browsermark.json', |
| 54 make_javascript_deterministic=False) | 54 make_javascript_deterministic=False) |
| 55 ps.AddPageWithDefaultRunNavigate('http://browsermark.rightware.com/tests/') | 55 ps.AddPageWithDefaultRunNavigate('http://browsermark.rightware.com/tests/') |
| 56 return ps | 56 return ps |
| OLD | NEW |