nashorn/test/script/basic/run-octane.js
author lagergren
Mon, 27 May 2013 13:11:13 +0200
changeset 17774 0407501fa563
parent 16525 1409942e618e
child 17777 3f0a680149b9
permissions -rw-r--r--
8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose Reviewed-by: jlaskey, attila
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
 * @subtest
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
var tests = [
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    29
    {file:"box2d",suite:"Box2DBenchmark"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    30
    {file:"code-load",suite:"CodeLoad"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    31
    {file:"crypto",suite:"Crypto"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    32
    {file:"deltablue",suite:"DeltaBlue"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    33
    {file:"earley-boyer", suite:"EarleyBoyer"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    34
    {file:"gbemu", suite:"GameboyBenchmark"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    35
    {file:"mandreel", suite:"MandreelBenchmark"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    36
    {file:"navier-stokes", suite:"NavierStokes"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    37
    {file:"pdfjs", suite:"PdfJS"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    38
    {file:"raytrace", suite:"RayTrace"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    39
    {file:"regexp", suite:"RegExpSuite"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    40
    {file:"richards", suite:"Richards"},
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    41
    {file:"splay", suite:"Splay"}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
// 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
    46
var path = dir + "../external/octane/";
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
var runtime = "";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
var verbose = false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
var numberOfIterations = 5;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
function endsWith(str, suffix) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    57
function should_compile_only(name) {
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    58
    return (typeof compile_only !== 'undefined')
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    59
}
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    60
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
function run_one_benchmark(arg, iters) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
    var file_name;
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    63
    var file = (arg.file + ".js").split('/');
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    64
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    65
    file_name = path + file[file.length - 1];
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    66
    
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    67
    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
    68
    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
    69
	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
    70
	    return;
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    71
	}
16201
889ddb179cdf 8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents: 16163
diff changeset
    72
    }
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    73
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    74
    print_verbose("Loading... " + file_name);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    75
    load(file_name);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    76
    
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    77
    if (compile_and_return) {
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    78
	print_always("Compiled OK: " + arg.file);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
	return;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    81
    
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
    var success = true;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
    var current_name;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
    
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
    if (iters == undefined) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
	iters = numberOfIterations;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
    } else {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
	numberOfIterations = iters;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
    }
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    90
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    91
    var benchmarks = eval(arg.suite + ".benchmarks");
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    92
    for (var x = 0; x < benchmarks.length ; x++) { 
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    93
	benchmarks[x].Setup();
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    94
    }
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    95
    print_verbose("Running '" + arg.file + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")");
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    96
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    97
    var scores = [];
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    98
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
    99
    var min_time_ms = min_time * 1000;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   100
    var len = benchmarks.length;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   101
    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   102
    for (var it = 0; it < iters + 1; it++) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   103
	//every iteration must take a minimum of 10 secs
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   104
	var ops = 0;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   105
	var elapsed = 0;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   106
	var start = new Date;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   107
	do {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   108
	    for (var i = 0; i < len; i++) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   109
		benchmarks[i].run();
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   110
	    }	    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   111
	    ops += len;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   112
	    elapsed = new Date - start;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   113
	} while (elapsed < min_time * 1000);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   114
	
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   115
	var score = ops / elapsed * 1000 * 60;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   116
	scores.push(score);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   117
	var name = it == 0 ? "warmup" : "iteration " + it;   
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   118
	print_verbose("[" + arg.file + "] " + name + " finished " + score.toFixed(0) + " ops/minute");
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   119
    }
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   120
    for (var x = 0; x < benchmarks.length ; x++) { 
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   121
	benchmarks[x].TearDown();
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   122
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   123
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   124
    var min_score  = 1e9;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   125
    var max_score  = 0;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   126
    var mean_score = 0;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   127
    for (var x = 1; x < iters + 1 ; x++) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   128
	mean_score += scores[x];
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   129
	min_score = Math.min(min_score, scores[x]);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   130
	max_score = Math.max(max_score, scores[x]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
    }
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   132
    mean_score /= iters;    
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   133
    var res = "[" + arg.file + "] " + mean_score.toFixed(0);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   134
    if (verbose) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   135
	res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   136
    }
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   137
    print_always(res);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   138
}
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   139
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   140
function print_always(x) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   141
    print(x);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   142
}
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   143
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   144
function print_verbose(x) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   145
    if (verbose) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   146
	print(x);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   147
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
function run_suite(tests, iters) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
    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
   152
	run_one_benchmark(tests[idx], iters);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
runtime = "command line";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   157
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   158
var args = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   159
if (typeof $ARGS !== 'undefined') {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   160
    args = $ARGS;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   161
} else if (typeof arguments !== 'undefined' && arguments.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   162
    args = arguments;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   163
}  
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   164
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   165
var new_args = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   166
for (i in args) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   167
    if (args[i].toString().indexOf(' ') != -1) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
	args[i] = args[i].replace(/\/$/, '');
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
	var s = args[i].split(' ');
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
	for (j in s) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
	    new_args.push(s[j]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   172
	}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
    } else {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
	new_args.push(args[i]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
if (new_args.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
    args = new_args;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
var tests_found = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
var iters = undefined;
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   184
var min_time = 5;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
for (var i = 0; i < args.length; i++) { 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
    arg = args[i];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
    if (arg == "--iterations") {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
	iters = +args[++i];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
    } else if (arg == "--runtime") {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
	runtime = args[++i];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
    } else if (arg == "--verbose") {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   193
	verbose = true;
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   194
    } else if (arg == "--min-time") {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   195
	min_time = +args[++i];
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
    } else if (arg == "") {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
	continue; //skip
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   198
    } else {
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   199
	var found = false;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   200
	for (j in tests) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   201
	    if (tests[j].file === arg) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   202
		tests_found.push(tests[j]);
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   203
		found = true;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   204
		break;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   205
	    }
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   206
	}
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   207
	if (!found) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   208
	    var str = "unknown test name: '" + arg + "' -- valid names are: ";
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   209
	    for (j in tests) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   210
		if (j != 0) {
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   211
		    str += ", ";
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   212
		}
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   213
		str += "'" + tests[j].file + "'";
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   214
	    }
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   215
	    throw str;
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   216
	}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   217
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   218
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   219
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   220
if (tests_found.length == 0) {    
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   221
    for (i in tests) {
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   222
	tests_found.push(tests[i]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   223
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   224
} 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   225
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
tests_found.sort();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   227
17774
0407501fa563 8014219: Make the run-octane harness more deterministic by not measuring elapsed time every iteration. Also got rid of most of the run logic in base.js and call benchmarks directly for the same purpose
lagergren
parents: 16525
diff changeset
   228
load(path + 'base.js');
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   229
run_suite(tests_found, iters);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   230
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   231
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   232