[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / perf / benchmarks / spaceport.py
blobf1ed01342849a799bdbc8293957af2f3b2bd8bc9
1 # Copyright 2012 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 spaceport.io's PerfMarks benchmark."""
7 import logging
8 import os
10 from core import perf_benchmark
12 from telemetry import benchmark
13 from telemetry.core import util
14 from telemetry import page as page_module
15 from telemetry.page import page_test
16 from telemetry import story
17 from telemetry.value import list_of_scalar_values
18 from telemetry.value import scalar
20 DESCRIPTIONS = {
21 'canvasDrawImageFullClear':
22 'Using a canvas element to render. Bitmaps are blitted to the canvas '
23 'using the "drawImage" function and the canvas is fully cleared at '
24 'the beginning of each frame.',
25 'canvasDrawImageFullClearAlign':
26 'Same as canvasDrawImageFullClear except all "x" and "y" values are '
27 'rounded to the nearest integer. This can be more efficient on '
28 'translate on certain browsers.',
29 'canvasDrawImagePartialClear':
30 'Using a canvas element to render. Bitmaps are blitted to the canvas '
31 'using the "drawImage" function and pixels drawn in the last frame '
32 'are cleared to the clear color at the beginning of each frame. '
33 'This is generally slower on hardware accelerated implementations, '
34 'but sometimes faster on CPU-based implementations.',
35 'canvasDrawImagePartialClearAlign':
36 'Same as canvasDrawImageFullClearAlign but only partially clearing '
37 'the canvas each frame.',
38 'css2dBackground':
39 'Using div elements that have a background image specified using CSS '
40 'styles. These div elements are translated, scaled, and rotated using '
41 'CSS-2D transforms.',
42 'css2dImg':
43 'Same as css2dBackground, but using img elements instead of div '
44 'elements.',
45 'css3dBackground':
46 'Same as css2dBackground, but using CSS-3D transforms.',
47 'css3dImg':
48 'Same as css2dImage but using CSS-3D tranforms.',
52 class _SpaceportMeasurement(page_test.PageTest):
53 def __init__(self):
54 super(_SpaceportMeasurement, self).__init__()
56 def CustomizeBrowserOptions(self, options):
57 options.AppendExtraBrowserArgs('--disable-gpu-vsync')
59 def ValidateAndMeasurePage(self, page, tab, results):
60 tab.WaitForJavaScriptExpression(
61 '!document.getElementById("start-performance-tests").disabled', 60)
63 tab.ExecuteJavaScript("""
64 window.__results = {};
65 window.console.log = function(str) {
66 if (!str) return;
67 var key_val = str.split(': ');
68 if (!key_val.length == 2) return;
69 __results[key_val[0]] = key_val[1];
71 document.getElementById('start-performance-tests').click();
72 """)
74 num_results = 0
75 num_tests_in_spaceport = 24
76 while num_results < num_tests_in_spaceport:
77 tab.WaitForJavaScriptExpression(
78 'Object.keys(window.__results).length > %d' % num_results, 180)
79 num_results = tab.EvaluateJavaScript(
80 'Object.keys(window.__results).length')
81 logging.info('Completed test %d of %d' %
82 (num_results, num_tests_in_spaceport))
84 result_dict = eval(tab.EvaluateJavaScript(
85 'JSON.stringify(window.__results)'))
86 for key in result_dict:
87 chart, trace = key.split('.', 1)
88 results.AddValue(scalar.ScalarValue(
89 results.current_page, '%s.%s'% (chart, trace),
90 'objects (bigger is better)', float(result_dict[key]),
91 important=False, description=DESCRIPTIONS.get(chart)))
92 results.AddValue(list_of_scalar_values.ListOfScalarValues(
93 results.current_page, 'Score', 'objects (bigger is better)',
94 [float(x) for x in result_dict.values()],
95 description='Combined score for all parts of the spaceport benchmark.'))
98 # crbug.com/166703: This test frequently times out on Windows.
99 @benchmark.Disabled('mac', 'win')
100 class Spaceport(perf_benchmark.PerfBenchmark):
101 """spaceport.io's PerfMarks benchmark.
103 http://spaceport.io/community/perfmarks
105 This test performs 3 animations (rotate, translate, scale) using a variety of
106 methods (css, webgl, canvas, etc) and reports the number of objects that can
107 be simultaneously animated while still achieving 30FPS.
109 test = _SpaceportMeasurement
111 @classmethod
112 def Name(cls):
113 return 'spaceport'
115 def CreateStorySet(self, options):
116 spaceport_dir = os.path.join(util.GetChromiumSrcDir(), 'chrome', 'test',
117 'data', 'third_party', 'spaceport')
118 ps = story.StorySet(base_dir=spaceport_dir)
119 ps.AddStory(page_module.Page('file://index.html', ps, ps.base_dir))
120 return ps