[Session restore] Rename group name Enabled to Restore.
[chromium-blink-merge.git] / tools / perf / benchmarks / maps.py
blob442fb41ed94477d44cc974fa8f085b922dc29540
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)"""
8 import os
9 import re
11 from telemetry import benchmark
12 from telemetry.core import util
13 from telemetry.page import page as page_module
14 from telemetry.page import page_set as page_set_module
15 from telemetry.page import page_test
16 from telemetry.value import scalar
19 class _MapsMeasurement(page_test.PageTest):
20 def __init__(self):
21 super(_MapsMeasurement, self).__init__()
23 def ValidateAndMeasurePage(self, page, tab, results):
24 js_get_results = 'document.getElementsByTagName("pre")[0].innerText'
25 test_results = tab.EvaluateJavaScript(js_get_results)
27 total = re.search('total=([0-9]+)', test_results).group(1)
28 render = re.search('render=([0-9.]+),([0-9.]+)', test_results).group(2)
29 results.AddValue(scalar.ScalarValue(
30 results.current_page, 'total_time', 'ms', int(total)))
31 results.AddValue(scalar.ScalarValue(
32 results.current_page, 'render_mean_time', 'ms', float(render)))
34 class MapsPage(page_module.Page):
35 def __init__(self, page_set, base_dir):
36 super(MapsPage, self).__init__(
37 url='http://localhost:10020/tracker.html',
38 page_set=page_set,
39 base_dir=base_dir,
40 make_javascript_deterministic=False)
42 def RunNavigateSteps(self, action_runner):
43 super(MapsPage, self).RunNavigateSteps(action_runner)
44 action_runner.WaitForJavaScriptCondition('window.testDone')
47 @benchmark.Disabled
48 class MapsBenchmark(benchmark.Benchmark):
49 """Basic Google Maps benchmarks."""
50 test = _MapsMeasurement
52 @classmethod
53 def Name(cls):
54 return 'maps'
56 def CreatePageSet(self, options):
57 page_set_path = os.path.join(
58 util.GetChromiumSrcDir(), 'tools', 'perf', 'page_sets')
59 ps = page_set_module.PageSet(
60 archive_data_file='data/maps.json', file_path=page_set_path,
61 bucket=page_set_module.PUBLIC_BUCKET)
62 ps.AddUserStory(MapsPage(ps, ps.base_dir))
63 return ps
65 class MapsNoVsync(MapsBenchmark):
66 """Runs the Google Maps benchmark with Vsync disabled"""
67 tag = 'novsync'
69 @classmethod
70 def Name(cls):
71 return 'maps.novsync'
73 def CustomizeBrowserOptions(self, options):
74 options.AppendExtraBrowserArgs('--disable-gpu-vsync')