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.
5 """Runs a Google Maps performance test.
6 Rerforms several common navigation actions on the map (pan, zoom, rotate)"""
11 from telemetry import test
12 from telemetry.core import util
13 from telemetry.page import page_measurement
14 from telemetry.page import page as page_module
15 from telemetry.page import page_set as page_set_module
16 # pylint: disable=W0401,W0614
17 from telemetry.page.actions.all_page_actions import *
20 class _MapsMeasurement(page_measurement.PageMeasurement):
21 def MeasurePage(self, page, tab, results):
22 js_get_results = 'document.getElementsByTagName("pre")[0].innerText'
23 test_results = tab.EvaluateJavaScript(js_get_results)
25 total = re.search('total=([0-9]+)', test_results).group(1)
26 render = re.search('render=([0-9.]+),([0-9.]+)', test_results).group(2)
27 results.Add('total_time', 'ms', total)
28 results.Add('render_mean_time', 'ms', render)
30 class MapsPage(page_module.Page):
31 def __init__(self, page_set, base_dir):
32 super(MapsPage, self).__init__(
33 url='http://localhost:10020/tracker.html',
37 def RunNavigateSteps(self, action_runner):
38 action_runner.Run(NavigateAction())
39 action_runner.Run(WaitAction({'javascript': 'window.testDone'}))
43 class MapsBenchmark(test.Test):
44 """Basic Google Maps benchmarks."""
45 test = _MapsMeasurement
47 def CreatePageSet(self, options):
48 page_set_path = os.path.join(
49 util.GetChromiumSrcDir(), 'tools', 'perf', 'page_sets')
50 ps = page_set_module.PageSet(
51 archive_data_file='data/maps.json',
52 make_javascript_deterministic=False,
53 file_path=page_set_path)
54 ps.AddPage(MapsPage(ps, ps.base_dir))
57 class MapsNoVsync(MapsBenchmark):
58 """Runs the Google Maps benchmark with Vsync disabled"""
61 def CustomizeBrowserOptions(self, options):
62 options.AppendExtraBrowserArgs('--disable-gpu-vsync')