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."""
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
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.',
39 'Using div elements that have a background image specified using CSS '
40 'styles. These div elements are translated, scaled, and rotated using '
43 'Same as css2dBackground, but using img elements instead of div '
46 'Same as css2dBackground, but using CSS-3D transforms.',
48 'Same as css2dImage but using CSS-3D tranforms.',
52 class _SpaceportMeasurement(page_test
.PageTest
):
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) {
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();
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 'linux', 'android') # crbug.com/525112
101 class Spaceport(perf_benchmark
.PerfBenchmark
):
102 """spaceport.io's PerfMarks benchmark.
104 http://spaceport.io/community/perfmarks
106 This test performs 3 animations (rotate, translate, scale) using a variety of
107 methods (css, webgl, canvas, etc) and reports the number of objects that can
108 be simultaneously animated while still achieving 30FPS.
110 test
= _SpaceportMeasurement
116 def CreateStorySet(self
, options
):
117 spaceport_dir
= os
.path
.join(util
.GetChromiumSrcDir(), 'chrome', 'test',
118 'data', 'third_party', 'spaceport')
119 ps
= story
.StorySet(base_dir
=spaceport_dir
)
120 ps
.AddStory(page_module
.Page('file://index.html', ps
, ps
.base_dir
))