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 telemetry
import benchmark
11 from telemetry
.core
import util
12 from telemetry
import page
as page_module
13 from telemetry
.page
import page_set
14 from telemetry
.page
import page_test
15 from telemetry
.value
import list_of_scalar_values
16 from telemetry
.value
import scalar
19 'canvasDrawImageFullClear':
20 'Using a canvas element to render. Bitmaps are blitted to the canvas '
21 'using the "drawImage" function and the canvas is fully cleared at '
22 'the beginning of each frame.',
23 'canvasDrawImageFullClearAlign':
24 'Same as canvasDrawImageFullClear except all "x" and "y" values are '
25 'rounded to the nearest integer. This can be more efficient on '
26 'translate on certain browsers.',
27 'canvasDrawImagePartialClear':
28 'Using a canvas element to render. Bitmaps are blitted to the canvas '
29 'using the "drawImage" function and pixels drawn in the last frame '
30 'are cleared to the clear color at the beginning of each frame. '
31 'This is generally slower on hardware accelerated implementations, '
32 'but sometimes faster on CPU-based implementations.',
33 'canvasDrawImagePartialClearAlign':
34 'Same as canvasDrawImageFullClearAlign but only partially clearing '
35 'the canvas each frame.',
37 'Using div elements that have a background image specified using CSS '
38 'styles. These div elements are translated, scaled, and rotated using '
41 'Same as css2dBackground, but using img elements instead of div '
44 'Same as css2dBackground, but using CSS-3D transforms.',
46 'Same as css2dImage but using CSS-3D tranforms.',
50 class _SpaceportMeasurement(page_test
.PageTest
):
52 super(_SpaceportMeasurement
, self
).__init
__()
54 def CustomizeBrowserOptions(self
, options
):
55 options
.AppendExtraBrowserArgs('--disable-gpu-vsync')
57 def ValidateAndMeasurePage(self
, page
, tab
, results
):
58 tab
.WaitForJavaScriptExpression(
59 '!document.getElementById("start-performance-tests").disabled', 60)
61 tab
.ExecuteJavaScript("""
62 window.__results = {};
63 window.console.log = function(str) {
65 var key_val = str.split(': ');
66 if (!key_val.length == 2) return;
67 __results[key_val[0]] = key_val[1];
69 document.getElementById('start-performance-tests').click();
73 num_tests_in_spaceport
= 24
74 while num_results
< num_tests_in_spaceport
:
75 tab
.WaitForJavaScriptExpression(
76 'Object.keys(window.__results).length > %d' % num_results
, 180)
77 num_results
= tab
.EvaluateJavaScript(
78 'Object.keys(window.__results).length')
79 logging
.info('Completed test %d of %d' %
80 (num_results
, num_tests_in_spaceport
))
82 result_dict
= eval(tab
.EvaluateJavaScript(
83 'JSON.stringify(window.__results)'))
84 for key
in result_dict
:
85 chart
, trace
= key
.split('.', 1)
86 results
.AddValue(scalar
.ScalarValue(
87 results
.current_page
, '%s.%s'% (chart
, trace
),
88 'objects (bigger is better)', float(result_dict
[key
]),
89 important
=False, description
=DESCRIPTIONS
.get(chart
)))
90 results
.AddValue(list_of_scalar_values
.ListOfScalarValues(
91 results
.current_page
, 'Score', 'objects (bigger is better)',
92 [float(x
) for x
in result_dict
.values()],
93 description
='Combined score for all parts of the spaceport benchmark.'))
96 # crbug.com/166703: This test frequently times out on Windows.
97 @benchmark.Disabled('mac', 'win')
98 class Spaceport(benchmark
.Benchmark
):
99 """spaceport.io's PerfMarks benchmark.
101 http://spaceport.io/community/perfmarks
103 This test performs 3 animations (rotate, translate, scale) using a variety of
104 methods (css, webgl, canvas, etc) and reports the number of objects that can
105 be simultaneously animated while still achieving 30FPS.
107 test
= _SpaceportMeasurement
113 def CreatePageSet(self
, options
):
114 spaceport_dir
= os
.path
.join(util
.GetChromiumSrcDir(), 'chrome', 'test',
115 'data', 'third_party', 'spaceport')
116 ps
= page_set
.PageSet(file_path
=spaceport_dir
)
117 ps
.AddUserStory(page_module
.Page('file://index.html', ps
, ps
.base_dir
))