test/script/basic/run-octane.js

Sat, 16 Nov 2013 00:23:46 +0100

author
hannesw
date
Sat, 16 Nov 2013 00:23:46 +0100
changeset 678
a165c0fb5be6
parent 298
e6193dcfe36c
child 693
18edd7a1b166
permissions
-rw-r--r--

8028210: Missing conversions on array index expression
Reviewed-by: attila, jlaskey, lagergren

     1 /*
     2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     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  */
    24 /**
    25  * @subtest
    26  */
    28 var tests = [
    29     {file:"box2d",suite:"Box2DBenchmark"},
    30     {file:"code-load",suite:"CodeLoad"},
    31     {file:"crypto",suite:"Crypto"},
    32     {file:"deltablue",suite:"DeltaBlue"},
    33     {file:"earley-boyer", suite:"EarleyBoyer"},
    34     {file:"gbemu", suite:"GameboyBenchmark"},
    35     {file:"mandreel", suite:"MandreelBenchmark"},
    36     {file:"navier-stokes", suite:"NavierStokes"},
    37     {file:"pdfjs", suite:"PdfJS"},
    38     {file:"raytrace", suite:"RayTrace"},
    39     {file:"regexp", suite:"RegExpSuite"},
    40     {file:"richards", suite:"Richards"},
    41     {file:"splay", suite:"Splay"}
    42 ];
    43 var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
    45 // TODO: why is this path hard coded when it's defined in project properties?
    46 var path = dir + "../external/octane/";
    48 var runtime = "";
    49 var verbose = false;
    51 var numberOfIterations = 5;
    53 function endsWith(str, suffix) {
    54     return str.indexOf(suffix, str.length - suffix.length) !== -1;
    55 }
    57 function should_compile_only(name) {
    58     return (typeof compile_only !== 'undefined')
    59 }
    61 function run_one_benchmark(arg, iters) {
    62     var file_name;
    63     var file = (arg.file + ".js").split('/');
    65     file_name = path + file[file.length - 1];
    67     var compile_and_return = should_compile_only(file_name);
    68     if (compile_and_return) {
    69 	if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them
    70 	    return;
    71 	}
    72     }
    74     print_verbose("Loading... " + file_name);
    75     load(file_name);
    77     if (compile_and_return) {
    78 	print_always("Compiled OK: " + arg.file);
    79 	return;
    80     }
    82     var success = true;
    83     var current_name;
    85     if (iters == undefined) {
    86 	iters = numberOfIterations;
    87     } else {
    88 	numberOfIterations = iters;
    89     }
    91     var benchmarks = eval(arg.suite + ".benchmarks");
    92     var min_score  = 1e9;
    93     var max_score  = 0;
    94     var mean_score = 0;
    96     try {
    97 	for (var x = 0; x < benchmarks.length ; x++) { 
    98 	    benchmarks[x].Setup();
    99 	}
   100 	print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")");
   102 	var scores = [];
   104 	var min_time_ms = min_time * 1000;
   105 	var len = benchmarks.length;    
   107 	for (var it = 0; it < iters + 1; it++) {
   108 	    //every iteration must take a minimum of 10 secs
   109 	    var ops = 0;
   110 	    var elapsed = 0;
   111 	    var start = new Date;
   112 	    do {
   113 		for (var i = 0; i < len; i++) {
   114 		    benchmarks[i].run();
   115 		}	    
   116 		ops += len;
   117 		elapsed = new Date - start;
   118 	    } while (elapsed < min_time * 1000);
   120 	    var score = ops / elapsed * 1000 * 60;
   121 	    scores.push(score);
   122 	    var name = it == 0 ? "warmup" : "iteration " + it;   
   123 	    print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute");
   124 	}
   126 	for (var x = 0; x < benchmarks.length ; x++) { 
   127 	    benchmarks[x].TearDown();
   128 	}
   130 	for (var x = 1; x < iters + 1 ; x++) {
   131 	    mean_score += scores[x];
   132 	    min_score = Math.min(min_score, scores[x]);
   133 	    max_score = Math.max(max_score, scores[x]);
   134 	}
   135 	mean_score /= iters;    
   137     } catch (e) {
   138 	print_always("*** Aborted and setting score to zero. Reason: " + e);
   139 	mean_score = min_score = max_score = 0;
   140 	scores = [0];
   141     }
   143     var res = "[" + arg.file + "] " + mean_score.toFixed(0);
   144     if (verbose) {
   145 	res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0);
   146     }
   147     print_always(res);
   148 }
   150 function print_always(x) {
   151     print(x);
   152 }
   154 function print_verbose(x) {
   155     if (verbose) {
   156 	print(x);
   157     }
   158 }
   160 function run_suite(tests, iters) {
   161     for (var idx = 0; idx < tests.length; idx++) {
   162 	run_one_benchmark(tests[idx], iters);
   163     }
   164 }
   166 runtime = "command line";
   168 var args = [];
   170 if (typeof $ARGS !== 'undefined') {
   171     args = $ARGS;
   172 } else if (typeof arguments !== 'undefined' && arguments.length != 0) {
   173     args = arguments;
   174 }  
   176 var new_args = [];
   177 for (i in args) {
   178     if (args[i].toString().indexOf(' ') != -1) {
   179 	args[i] = args[i].replace(/\/$/, '');
   180 	var s = args[i].split(' ');
   181 	for (j in s) {
   182 	    new_args.push(s[j]);
   183 	}
   184     } else {
   185 	new_args.push(args[i]);
   186     }
   187 }
   189 if (new_args.length != 0) {
   190     args = new_args;
   191 }
   193 var tests_found = [];
   194 var iters = undefined;
   195 var min_time = 5;
   197 for (var i = 0; i < args.length; i++) { 
   198     arg = args[i];
   199     if (arg == "--iterations") {
   200 	iters = +args[++i];
   201     } else if (arg == "--runtime") {
   202 	runtime = args[++i];
   203     } else if (arg == "--verbose") {
   204 	verbose = true;
   205     } else if (arg == "--min-time") {
   206 	min_time = +args[++i];
   207     } else if (arg == "") {
   208 	continue; //skip
   209     } else {
   210 	var found = false;
   211 	for (j in tests) {
   212 	    if (tests[j].file === arg) {
   213 		tests_found.push(tests[j]);
   214 		found = true;
   215 		break;
   216 	    }
   217 	}
   218 	if (!found) {
   219 	    var str = "unknown test name: '" + arg + "' -- valid names are: ";
   220 	    for (j in tests) {
   221 		if (j != 0) {
   222 		    str += ", ";
   223 		}
   224 		str += "'" + tests[j].file + "'";
   225 	    }
   226 	    throw str;
   227 	}
   228     }
   229 }
   231 if (tests_found.length == 0) {    
   232     for (i in tests) {
   233 	tests_found.push(tests[i]);
   234     }
   235 } 
   237 tests_found.sort();
   239 load(path + 'base.js');
   240 run_suite(tests_found, iters);

mercurial