Mojo C++ bindings: better log message for serialization warnings.
[chromium-blink-merge.git] / tools / perf / benchmarks / canvasmark.py
blob55a219b338c60d4fa30c70fd8e6589683cfb98a7
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 Canvasmark HTML5, Canvas 2D rendering and javascript benchmark.
7 CanvasMark tests the HTML5 <canvas> rendering performance for commonly used
8 operations in HTML5 games: bitmaps, canvas drawing, alpha blending, polygon
9 fills, shadows and text functions.
10 """
12 import os
14 from telemetry import benchmark
15 from telemetry.page import page_set
16 from telemetry.page import page_test
17 from telemetry.value import scalar
20 class _CanvasMarkMeasurement(page_test.PageTest):
22 def WillNavigateToPage(self, page, tab):
23 page.script_to_evaluate_on_commit = """
24 var __results = [];
25 var __real_log = window.console.log;
26 window.console.log = function(msg) {
27 __results.push(msg);
28 __real_log.apply(this, [msg]);
30 """
32 def ValidateAndMeasurePage(self, _, tab, results):
33 tab.WaitForJavaScriptExpression('__results.length == 8', 300)
34 results_log = tab.EvaluateJavaScript('__results')
35 total = 0
36 for output in results_log:
37 # Split the results into score and test name.
38 # results log e.g., "489 [Test 1 - Asteroids - Bitmaps]"
39 score_and_name = output.split(' [', 2)
40 assert len(score_and_name) == 2, \
41 'Unexpected result format "%s"' % score_and_name
42 score = int(score_and_name[0])
43 name = score_and_name[1][:-1]
44 results.AddValue(scalar.ScalarValue(
45 results.current_page, name, 'score', score, important=False))
46 # Aggregate total score for all tests.
47 total += score
48 results.AddValue(scalar.ScalarValue(
49 results.current_page, 'Score', 'score', total))
52 @benchmark.Disabled
53 class CanvasMark(benchmark.Benchmark):
54 test = _CanvasMarkMeasurement
56 def CreatePageSet(self, options):
57 ps = page_set.PageSet(
58 file_path=os.path.abspath(__file__),
59 archive_data_file='../page_sets/data/canvasmark.json',
60 make_javascript_deterministic=False)
61 ps.AddPageWithDefaultRunNavigate(
62 'http://www.kevs3d.co.uk/dev/canvasmark/?auto=true')
63 return ps