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