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 Octane 2.0 javascript benchmark.
7 Octane 2.0 is a modern benchmark that measures a JavaScript engine's performance
8 by running a suite of tests representative of today's complex and demanding web
9 applications. Octane's goal is to measure the performance of JavaScript code
10 found in large, real-world web applications.
11 Octane 2.0 consists of 17 tests, four more than Octane v1.
16 from metrics
import power
17 from telemetry
import benchmark
18 from telemetry
.page
import page_set
19 from telemetry
.page
import page_test
20 from telemetry
.util
import statistics
21 from telemetry
.value
import scalar
23 _GB
= 1024 * 1024 * 1024
27 'Measures how quickly a JavaScript engine can start executing code '
28 'after loading a large JavaScript program, social widget being a common '
29 'example. The source for test is derived from open source libraries '
30 '(Closure, jQuery) (1,530 lines).',
32 'Encryption and decryption benchmark based on code by Tom Wu '
35 'One-way constraint solver, originally written in Smalltalk by John '
36 'Maloney and Mario Wolczko (880 lines).',
38 'Classic Scheme benchmarks, translated to JavaScript by Florian '
39 'Loitsch\'s Scheme2Js compiler (4684 lines).',
41 'Emulate the portable console\'s architecture and runs a demanding 3D '
42 'simulation, all in JavaScript (11,097 lines).',
44 'Runs the 3D Bullet Physics Engine ported from C++ to JavaScript via '
45 'Mandreel (277,377 lines).',
47 '2D NavierStokes equations solver, heavily manipulates double precision '
48 'arrays. Based on Oliver Hunt\'s code (387 lines).',
50 'Mozilla\'s PDF Reader implemented in JavaScript. It measures decoding '
51 'and interpretation time (33,056 lines).',
53 'Ray tracer benchmark based on code by Adam Burmister (904 lines).',
55 'Regular expression benchmark generated by extracting regular '
56 'expression operations from 50 of the most popular web pages '
59 'OS kernel simulation benchmark, originally written in BCPL by Martin '
60 'Richards (539 lines).',
62 'Data manipulation benchmark that deals with splay trees and exercises '
63 'the automatic memory management subsystem (394 lines).',
67 class _OctaneMeasurement(page_test
.PageTest
):
69 super(_OctaneMeasurement
, self
).__init
__()
70 self
._power
_metric
= None
72 def CustomizeBrowserOptions(self
, options
):
73 power
.PowerMetric
.CustomizeBrowserOptions(options
)
75 def WillStartBrowser(self
, browser
):
76 self
._power
_metric
= power
.PowerMetric(browser
)
78 def WillNavigateToPage(self
, page
, tab
):
79 memory_stats
= tab
.browser
.memory_stats
80 if ('SystemTotalPhysicalMemory' in memory_stats
and
81 memory_stats
['SystemTotalPhysicalMemory'] < 1 * _GB
):
82 skipBenchmarks
= '"zlib"'
85 page
.script_to_evaluate_on_commit
= """
87 var __real_log = window.console.log;
88 window.console.log = function(msg) {
90 __real_log.apply(this, [msg]);
93 """ % (skipBenchmarks
)
95 def DidNavigateToPage(self
, page
, tab
):
96 self
._power
_metric
.Start(page
, tab
)
98 def ValidateAndMeasurePage(self
, page
, tab
, results
):
99 tab
.WaitForJavaScriptExpression(
100 'completed && !document.getElementById("progress-bar-container")', 1200)
102 self
._power
_metric
.Stop(page
, tab
)
103 self
._power
_metric
.AddResults(tab
, results
)
105 results_log
= tab
.EvaluateJavaScript('__results')
107 for output
in results_log
:
108 # Split the results into score and test name.
109 # results log e.g., "Richards: 18343"
110 score_and_name
= output
.split(': ', 2)
111 assert len(score_and_name
) == 2, \
112 'Unexpected result format "%s"' % score_and_name
113 if 'Skipped' not in score_and_name
[1]:
114 name
= score_and_name
[0]
115 score
= int(score_and_name
[1])
116 results
.AddValue(scalar
.ScalarValue(
117 results
.current_page
, name
, 'score', score
, important
=False,
118 description
=DESCRIPTIONS
.get(name
)))
120 # Collect all test scores to compute geometric mean.
121 all_scores
.append(score
)
122 total
= statistics
.GeometricMean(all_scores
)
123 results
.AddSummaryValue(
124 scalar
.ScalarValue(None, 'Total.Score', 'score', total
,
125 description
='Geometric mean of the scores of each '
126 'individual benchmark in the Octane '
127 'benchmark collection.'))
130 class Octane(benchmark
.Benchmark
):
131 """Google's Octane JavaScript benchmark."""
132 test
= _OctaneMeasurement
134 def CreatePageSet(self
, options
):
135 ps
= page_set
.PageSet(
136 archive_data_file
='../page_sets/data/octane.json',
137 make_javascript_deterministic
=False,
138 file_path
=os
.path
.abspath(__file__
))
139 ps
.AddPageWithDefaultRunNavigate(
140 'http://octane-benchmark.googlecode.com/svn/latest/index.html?auto=1')