author | lagergren |
Thu, 14 Mar 2013 14:49:55 +0100 | |
changeset 16525 | 1409942e618e |
parent 16201 | 889ddb179cdf |
child 17774 | 0407501fa563 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @subtest |
|
26 |
*/ |
|
27 |
||
28 |
var tests = [ |
|
29 |
"box2d.js", |
|
30 |
"code-load.js", |
|
31 |
"crypto.js", |
|
32 |
"deltablue.js", |
|
33 |
"earley-boyer.js", |
|
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
34 |
"gbemu.js", |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
35 |
"mandreel.js", |
16147 | 36 |
"navier-stokes.js", |
37 |
"pdfjs.js", |
|
38 |
"raytrace.js", |
|
39 |
"regexp.js", |
|
40 |
"richards.js", |
|
41 |
"splay.js" |
|
42 |
]; |
|
43 |
||
44 |
// hack, teardown breaks things defined in the global space, making it impossible |
|
45 |
// to do multiple consecutive benchmark runs with the same harness. I think it's a bug |
|
46 |
// that the setup and teardown aren't each others constructor and destructor but rather |
|
47 |
// that the benchmarks rely on partial global state. For shame, Octane! |
|
48 |
var ignoreTeardown = [ |
|
49 |
{ name: "box2d.js" }, |
|
50 |
{ name: "gbemu.js" }, |
|
51 |
]; |
|
52 |
||
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
53 |
|
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
54 |
//TODO mandreel can be compiled as a test, but not run multiple times unless modified to not have global state |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
55 |
var compileOnly = { |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
56 |
"mandreel.js" : true |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
57 |
}; |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
58 |
|
16147 | 59 |
var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__; |
60 |
||
61 |
// TODO: why is this path hard coded when it's defined in project properties? |
|
16163
71f4cff209a9
8005940: provide ant targets to get and update external test scripts
sundar
parents:
16151
diff
changeset
|
62 |
var path = dir + "../external/octane/"; |
16147 | 63 |
|
64 |
var runtime = ""; |
|
65 |
var verbose = false; |
|
66 |
||
67 |
var numberOfIterations = 5; |
|
68 |
||
69 |
function endsWith(str, suffix) { |
|
70 |
return str.indexOf(suffix, str.length - suffix.length) !== -1; |
|
71 |
} |
|
72 |
||
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
73 |
function should_compile_only(name) { |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
74 |
return (typeof compile_only !== 'undefined') || compileOnly[name] === true; |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
75 |
} |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
76 |
|
16147 | 77 |
function run_one_benchmark(arg, iters) { |
78 |
||
79 |
var file_name; |
|
80 |
var file = arg.split('/'); |
|
81 |
if (file.length == 1) { |
|
82 |
file = arg.split('\\'); |
|
83 |
} |
|
84 |
||
85 |
//trim off trailing path separators |
|
86 |
while (file[file.length - 1].indexOf(".js") == -1) { |
|
87 |
file.pop(); |
|
88 |
} |
|
89 |
file_name = file[file.length - 1]; |
|
16201
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
90 |
|
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
91 |
var compile_and_return = should_compile_only(file_name); |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
92 |
if (compile_and_return) { |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
93 |
if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
94 |
return; |
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
95 |
} |
16201
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
96 |
print("Compiling... " + file_name); |
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
97 |
} |
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
98 |
|
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
99 |
load(path + 'base.js'); |
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
100 |
load(arg); |
16147 | 101 |
|
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
102 |
if (compile_and_return) { |
16147 | 103 |
print("Compiled OK: " + file_name); |
16201
889ddb179cdf
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents:
16163
diff
changeset
|
104 |
print(""); |
16147 | 105 |
return; |
106 |
} |
|
107 |
||
108 |
var success = true; |
|
109 |
var hiscore = 0; |
|
110 |
var loscore = 10e8; |
|
111 |
var current_name; |
|
112 |
||
113 |
function PrintResult(name, result) { |
|
114 |
current_name = name; |
|
115 |
} |
|
116 |
||
117 |
function PrintError(name, error) { |
|
118 |
current_name = name; |
|
119 |
PrintResult(name, error); |
|
120 |
success = false; |
|
121 |
} |
|
122 |
||
123 |
function PrintScore(score) { |
|
124 |
if (success) { |
|
125 |
if (+score >= hiscore) { |
|
126 |
hiscore = +score; |
|
127 |
} |
|
128 |
if (+score <= loscore) { |
|
129 |
loscore = +score; |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
if (verbose) { |
|
134 |
print("Score: " + score); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
if (iters == undefined) { |
|
139 |
iters = numberOfIterations; |
|
140 |
} else { |
|
141 |
numberOfIterations = iters; |
|
142 |
} |
|
143 |
||
144 |
print(runtime + ": running " + file_name + "..."); |
|
145 |
||
146 |
for (var i = 0; i < numberOfIterations; i++) { |
|
147 |
var callbacks = |
|
148 |
{ NotifyResult: PrintResult, |
|
149 |
NotifyError: PrintError, |
|
150 |
NotifyScore: PrintScore }; |
|
151 |
||
152 |
for (j in ignoreTeardown) { |
|
153 |
var ignore = ignoreTeardown[j]; |
|
154 |
if (endsWith(arg, ignore.name)) { |
|
155 |
var teardownOverride = ignore.teardown; |
|
156 |
if (!teardownOverride) { |
|
157 |
teardownOverride = function() {}; |
|
158 |
} |
|
159 |
||
160 |
for (k in BenchmarkSuite.suites) { |
|
161 |
var benchmarks = BenchmarkSuite.suites[k].benchmarks; |
|
162 |
for (l in benchmarks) { |
|
163 |
benchmarks[l].TearDown = teardownOverride; |
|
164 |
} |
|
165 |
} |
|
166 |
break; |
|
167 |
} |
|
168 |
} |
|
169 |
||
170 |
BenchmarkSuite.RunSuites(callbacks); |
|
171 |
} |
|
172 |
||
173 |
var start = "Score: "; |
|
174 |
if (runtime != "") { |
|
175 |
start = runtime + ": "; |
|
176 |
} |
|
177 |
print(start + current_name + ' (version ' + BenchmarkSuite.version + '): ' + loscore + '-' + hiscore); |
|
178 |
} |
|
179 |
||
180 |
function run_suite(tests, iters) { |
|
181 |
for (var idx = 0; idx < tests.length; idx++) { |
|
16525
1409942e618e
8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents:
16201
diff
changeset
|
182 |
run_one_benchmark(tests[idx], iters); |
16147 | 183 |
} |
184 |
} |
|
185 |
||
186 |
runtime = "command line"; |
|
187 |
||
188 |
var args = []; |
|
189 |
if (typeof $ARGS !== 'undefined') { |
|
190 |
args = $ARGS; |
|
191 |
} else if (typeof arguments !== 'undefined' && arguments.length != 0) { |
|
192 |
args = arguments; |
|
193 |
} |
|
194 |
||
195 |
var new_args = []; |
|
196 |
for (i in args) { |
|
197 |
if (args[i].toString().indexOf(' ') != -1) { |
|
198 |
args[i] = args[i].replace(/\/$/, ''); |
|
199 |
var s = args[i].split(' '); |
|
200 |
for (j in s) { |
|
201 |
new_args.push(s[j]); |
|
202 |
} |
|
203 |
} else { |
|
204 |
new_args.push(args[i]); |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
if (new_args.length != 0) { |
|
209 |
args = new_args; |
|
210 |
} |
|
211 |
||
212 |
var tests_found = []; |
|
213 |
var iters = undefined; |
|
214 |
||
215 |
for (var i = 0; i < args.length; i++) { |
|
216 |
arg = args[i]; |
|
217 |
if (arg == "--iterations") { |
|
218 |
iters = +args[++i]; |
|
219 |
} else if (arg == "--runtime") { |
|
220 |
runtime = args[++i]; |
|
221 |
} else if (arg == "--verbose") { |
|
222 |
verbose = true; |
|
223 |
} else if (arg == "") { |
|
224 |
continue; //skip |
|
225 |
} else { |
|
226 |
tests_found.push(arg); |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
if (tests_found.length == 0) { |
|
231 |
for (i in tests) { |
|
232 |
tests_found.push(path + tests[i]); |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
tests_found.sort(); |
|
237 |
||
238 |
run_suite(tests_found, iters); |
|
239 |
||
240 |
||
241 |