nashorn/test/script/basic/run-octane.js
author hannesw
Thu, 04 Sep 2014 15:37:14 +0200
changeset 26377 028dad61662f
parent 25821 fbb51e67d2a7
child 26768 751b0f427090
permissions -rw-r--r--
8051889: Implement block scoping in symbol assignment and scope computation Reviewed-by: attila, lagergren
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.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
     4
 *
16147
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.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
     8
 *
16147
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).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    14
 *
16147
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.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    18
 *
16147
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
 */
25821
fbb51e67d2a7 8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents: 24778
diff changeset
    27
var payload = __DIR__ + "octane-payload.js";
fbb51e67d2a7 8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents: 24778
diff changeset
    28
load(payload);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
    30
var runtime = undefined;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
var verbose = false;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
var numberOfIterations = 5;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    35
function endsWith(str, suffix) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
    return str.indexOf(suffix, str.length - suffix.length) !== -1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    39
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
    40
    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
    41
}
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    42
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    43
function load_bench(arg) {
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    44
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    45
    for (var idx = 0; idx < arg.files.length; idx++) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    46
    var f = arg.files[idx];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    47
    var file = f.split('/');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    48
    var file_name = path + file[file.length - 1];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    49
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    50
    var compile_and_return = should_compile_only(file_name);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    51
    if (compile_and_return) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    52
        if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    53
        return true;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    54
        }
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    55
    }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    56
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    57
    print_verbose(arg, "loading '" + arg.name + "' [" + f + "]...");
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    58
    load(file_name);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    59
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    60
24743
138ee369abd8 8033105: Make sure Nashorn test harness can run zlib benchmark
lagergren
parents: 24740
diff changeset
    61
    if (typeof arg.before !== 'undefined') {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    62
    arg.before();
24743
138ee369abd8 8033105: Make sure Nashorn test harness can run zlib benchmark
lagergren
parents: 24740
diff changeset
    63
    }
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    64
16525
1409942e618e 8009982: Lazy execution bugfix. Added lazy sunspider unit test. Added mandreel to compile-octane test. Fixed warnings
lagergren
parents: 16201
diff changeset
    65
    if (compile_and_return) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    66
    print_always(arg, "Compiled OK");
16201
889ddb179cdf 8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
lagergren
parents: 16163
diff changeset
    67
    }
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    68
    return !compile_and_return;
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    69
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    70
}
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    71
24743
138ee369abd8 8033105: Make sure Nashorn test harness can run zlib benchmark
lagergren
parents: 24740
diff changeset
    72
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    73
function run_one_benchmark(arg, iters) {
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    74
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
    75
    if (!load_bench(arg)) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    76
    return;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    77
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    78
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
    var success = true;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
    var current_name;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    81
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
    if (iters == undefined) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    83
    iters = numberOfIterations;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
    } else {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    85
    numberOfIterations = iters;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
    }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    87
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
    88
    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
    89
    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
    90
    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
    91
    var mean_score = 0;
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
    92
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
    93
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    94
    for (var x = 0; x < benchmarks.length ; x++) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    95
        //do warmup run
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    96
        //reset random number generator needed as of octane 9 before each run
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    97
        BenchmarkSuite.ResetRNG();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    98
        benchmarks[x].Setup();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    99
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   100
    BenchmarkSuite.ResetRNG();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   101
    print_verbose(arg, "running '" + arg.name + "' for " + iters + " iterations of no less than " + min_time + " seconds");
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   102
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   103
    var scores = [];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   104
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   105
    var min_time_ms = min_time * 1000;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   106
    var len = benchmarks.length;
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
   107
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   108
    for (var it = 0; it < iters + 1; it++) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   109
        //every iteration must take a minimum of 10 secs
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   110
        var ops = 0;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   111
        var elapsed = 0;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   112
        var start = new Date;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   113
        do {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   114
        for (var i = 0; i < len; i++) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   115
            benchmarks[i].run();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   116
            //important - no timing here like elapsed = new Date() - start, as in the
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   117
            //original harness. This will make timing very non-deterministic.
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   118
            //NOTHING else must live in this loop
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   119
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   120
        ops += len;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   121
        elapsed = new Date - start;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   122
        } while (elapsed < min_time * 1000);
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
   123
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   124
        var score = ops / elapsed * 1000 * 60;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   125
        scores.push(score);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   126
        var name = it == 0 ? "warmup" : "iteration " + it;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   127
        print_verbose(arg, name + " finished " + score.toFixed(0) + " ops/minute");
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   128
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   129
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   130
    for (var x = 0; x < benchmarks.length ; x++) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   131
        benchmarks[x].TearDown();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   132
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   133
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   134
    for (var x = 1; x < iters + 1 ; x++) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   135
        mean_score += scores[x];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   136
        min_score = Math.min(min_score, scores[x]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   137
        max_score = Math.max(max_score, scores[x]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   138
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   139
    mean_score /= iters;
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
   140
    } catch (e) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   141
    print_always(arg, "*** Aborted and setting score to zero. Reason: " + e);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   142
    if (e instanceof java.lang.Throwable) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   143
        e.printStackTrace();
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   144
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   145
    mean_score = min_score = max_score = 0;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   146
    scores = [0];
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
    }
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
   148
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   149
    var res = mean_score.toFixed(0);
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
   150
    if (verbose) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   151
    res += " ops/minute (" + min_score.toFixed(0) + "-" + max_score.toFixed(0) + "), warmup=" + scores[0].toFixed(0);
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
   152
    }
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   153
    print_always(arg, res);
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
   154
}
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
   155
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   156
function runtime_string() {
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   157
    return runtime == undefined ? "" : ("[" + runtime + "] ");
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   158
}
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   159
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   160
function print_always(arg, x) {
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   161
    print(runtime_string() + "[" + arg.name + "] " + x);
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
   162
}
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
   163
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   164
function print_verbose(arg, x) {
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
   165
    if (verbose) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   166
    print_always(arg, x)
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
   167
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   170
function run_suite(tests, iters) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
    for (var idx = 0; idx < tests.length; idx++) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   172
    run_one_benchmark(tests[idx], iters);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
var args = [];
17777
3f0a680149b9 8015447: Octane harness fixes for rhino and entire test runs: ant octane, ant octane-v8, ant octane-rhino
lagergren
parents: 17774
diff changeset
   177
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
if (typeof $ARGS !== 'undefined') {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
    args = $ARGS;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
} else if (typeof arguments !== 'undefined' && arguments.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
    args = arguments;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   182
}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
var new_args = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
for (i in args) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
    if (args[i].toString().indexOf(' ') != -1) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   187
    args[i] = args[i].replace(/\/$/, '');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   188
    var s = args[i].split(' ');
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   189
    for (j in s) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   190
        new_args.push(s[j]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   191
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
    } else {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   193
    new_args.push(args[i]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   194
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   195
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
if (new_args.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   198
    args = new_args;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   199
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   200
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   201
var tests_found = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   202
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
   203
var min_time = 5;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   204
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   205
for (var i = 0; i < args.length; i++) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   206
    arg = args[i];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   207
    if (arg == "--iterations") {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   208
    iters = +args[++i];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   209
    if (isNaN(iters)) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   210
        throw "'--iterations' must be followed by integer";
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   211
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   212
    } else if (arg == "--runtime") {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   213
    runtime = args[++i];
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   214
    } else if (arg == "--verbose") {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   215
    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
   216
    } else if (arg == "--min-time") {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   217
    min_time = +args[++i];
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   218
    if (isNaN(iters)) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   219
        throw "'--min-time' must be followed by integer";
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   220
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   221
    } else if (arg == "") {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   222
    continue; //skip
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   223
    } else {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   224
    var found = false;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   225
    for (j in tests) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   226
        if (tests[j].name === arg) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   227
        tests_found.push(tests[j]);
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   228
        found = true;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   229
        break;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   230
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   231
    }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   232
    if (!found) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   233
        var str = "unknown test name: '" + arg + "' -- valid names are: ";
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   234
        for (j in tests) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   235
        if (j != 0) {
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   236
            str += ", ";
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   237
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   238
        str += "'" + tests[j].name + "'";
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   239
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   240
        throw str;
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   241
    }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   242
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   243
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   244
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   245
if (tests_found.length == 0) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   246
    for (i in tests) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   247
    tests_found.push(tests[i]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   248
    }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   249
}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   250
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   251
// returns false for rhino, v8 and all other javascript runtimes, true for Nashorn
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   252
function is_this_nashorn() {
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   253
    return typeof Error.dumpStack == 'function'
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   254
}
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   255
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   256
if (is_this_nashorn()) {
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   257
    try {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   258
    read = readFully;
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   259
    } catch (e) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   260
    print("ABORTING: Cannot find 'readFully'. You must have scripting enabled to use this test harness. (-scripting)");
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   261
    throw e;
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   262
    }
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   263
}
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   264
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   265
// run tests in alphabetical order by name
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   266
tests_found.sort(function(a, b) {
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   267
    if (a.name < b.name) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   268
    return -1;
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   269
    } else if (a.name > b.name) {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   270
    return 1;
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   271
    } else {
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   272
    return 0;
24767
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   273
    }
0b8af588070b 8044012: Integrate the latest best known performance flags int ant octane jobs, and make sure that it's easy to compare 'ant octane-nashorn' and 'ant octane-v8' at the push of a button. (or rather; the entry of a command line)
lagergren
parents: 24761
diff changeset
   274
});
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   275
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
   276
load(path + 'base.js');
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   277
run_suite(tests_found, iters);