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 a Google Maps performance test. 6 Rerforms several common navigation actions on the map (pan, zoom, rotate)""" 7 8 import os 9 import re 10 11 from telemetry import test 12 from telemetry.core import util 13 from telemetry.page import page_measurement 14 from telemetry.page import page_set 15 16 class MapsMeasurement(page_measurement.PageMeasurement): 17 def MeasurePage(self, page, tab, results): 18 js_get_results = 'document.getElementsByTagName("pre")[0].innerText' 19 test_results = tab.EvaluateJavaScript(js_get_results) 20 21 total = re.search('total=([0-9]+)', test_results).group(1) 22 render = re.search('render=([0-9.]+),([0-9.]+)', test_results).group(2) 23 results.Add('total_time', 'ms', total) 24 results.Add('render_mean_time', 'ms', render) 25 26 class MapsBenchmark(test.Test): 27 """Basic Google Maps benchmarks.""" 28 test = MapsMeasurement 29 enabled = False 30 31 def CreatePageSet(self, options): 32 page_set_path = os.path.join( 33 util.GetChromiumSrcDir(), 'tools', 'perf', 'page_sets') 34 page_set_dict = { 35 'archive_data_file': 'data/maps.json', 36 'make_javascript_deterministic': False, 37 'pages': [ 38 { 39 'url': 'http://localhost:10020/tracker.html', 40 'navigate_steps' : [ 41 { 'action': 'navigate' }, 42 { 'action': 'wait', 'javascript': 'window.testDone' } 43 ] 44 } 45 ] 46 } 47 48 return page_set.PageSet.FromDict(page_set_dict, page_set_path) 49 50 class MapsNoVsync(MapsBenchmark): 51 """Runs the Google Maps benchmark with Vsync disabled""" 52 tag = 'novsync' 53 54 def CustomizeBrowserOptions(self, options): 55 options.AppendExtraBrowserArgs('--disable-gpu-vsync') 56