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 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
):
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',
40 make_javascript_deterministic
=False)
42 def RunNavigateSteps(self
, action_runner
):
43 super(MapsPage
, self
).RunNavigateSteps(action_runner
)
44 action_runner
.WaitForJavaScriptCondition('window.testDone')
48 class MapsBenchmark(benchmark
.Benchmark
):
49 """Basic Google Maps benchmarks."""
50 test
= _MapsMeasurement
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
))
65 class MapsNoVsync(MapsBenchmark
):
66 """Runs the Google Maps benchmark with Vsync disabled"""
73 def CustomizeBrowserOptions(self
, options
):
74 options
.AppendExtraBrowserArgs('--disable-gpu-vsync')