test/script/basic/run-octane.js

Wed, 03 Apr 2013 11:13:08 +0200

author
attila
date
Wed, 03 Apr 2013 11:13:08 +0200
changeset 166
51da1afbab26
parent 139
390d44ba90cf
child 295
1f57afd14cc1
permissions
-rw-r--r--

8011362: Overloaded method resolution foiled by nulls
Reviewed-by: hannesw, sundar

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

mercurial