nashorn/test/script/basic/run-octane.js
author hannesw
Fri, 03 Feb 2017 13:28:00 +0100
changeset 43555 1bb10bccf057
parent 26980 381b7cf1729a
permissions -rw-r--r--
8173888: Test for JDK-8169481 causes stack overflows in parser tests Reviewed-by: jlaskey, sundar
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
 */
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    27
var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    28
load(dir + "octane-payload.js");
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++) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    46
        var f = arg.files[idx];
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    47
        var file = f.split('/');
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    48
        var file_name = path + file[file.length - 1];
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    49
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    50
        var compile_and_return = should_compile_only(file_name);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    51
        if (compile_and_return) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    52
            if (typeof compile_only === 'undefined') { //for a run, skip compile onlies, don't even compile them
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    53
                return true;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    54
            }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    55
        }
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    56
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    57
        print_verbose(arg, "loading '" + arg.name + "' [" + f + "]... " + file_name);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    58
        load(file_name);
24778
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') {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
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) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
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)) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    76
        return;
24778
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) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    83
        iters = numberOfIterations;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
    } else {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
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 {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    94
        for (var x = 0; x < benchmarks.length ; x++) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    95
            //do warmup run
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    96
            //reset random number generator needed as of octane 9 before each run
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    97
            BenchmarkSuite.ResetRNG();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
    98
            benchmarks[x].Setup();
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
    99
        }
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   100
        BenchmarkSuite.ResetRNG();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   101
        print_verbose(arg, "running '" + arg.name + "' for " + iters + " iterations of no less than " + min_time + " seconds");
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   102
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   103
        var scores = [];
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   104
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   105
        var min_time_ms = min_time * 1000;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
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
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   108
        for (var it = 0; it < iters + 1; it++) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   109
            //every iteration must take a minimum of 10 secs
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   110
            var ops = 0;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   111
            var elapsed = 0;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   112
            var start = new Date;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   113
            do {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   114
                for (var i = 0; i < len; i++) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   115
                    benchmarks[i].run();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   116
                    //important - no timing here like elapsed = new Date() - start, as in the
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   117
                    //original harness. This will make timing very non-deterministic.
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   118
                    //NOTHING else must live in this loop
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   119
                }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   120
                ops += len;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   121
                elapsed = new Date - start;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   122
            } while (elapsed < min_time * 1000);
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   123
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   124
            var score = ops / elapsed * 1000 * 60;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   125
            scores.push(score);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   126
            var name = it == 0 ? "warmup" : "iteration " + it;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   127
            print_verbose(arg, name + " finished " + score.toFixed(0) + " ops/minute");
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   128
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   129
            // optional per-iteration cleanup hook
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   130
            if (typeof arg.cleanUpIteration == "function") {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   131
                arg.cleanUpIteration();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   132
            }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   133
        }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   134
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   135
        for (var x = 0; x < benchmarks.length ; x++) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   136
            benchmarks[x].TearDown();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   137
        }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   138
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   139
        for (var x = 1; x < iters + 1 ; x++) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   140
            mean_score += scores[x];
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   141
            min_score = Math.min(min_score, scores[x]);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   142
            max_score = Math.max(max_score, scores[x]);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   143
        }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   144
        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
   145
    } catch (e) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   146
        print_always(arg, "*** Aborted and setting score to zero. Reason: " + e);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   147
        if (is_this_nashorn() && e instanceof java.lang.Throwable) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   148
            e.printStackTrace();
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   149
        }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   150
        mean_score = min_score = max_score = 0;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   151
        scores = [0];
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
    }
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
   153
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   154
    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
   155
    if (verbose) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   156
        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
   157
    }
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   158
    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
   159
}
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
   160
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
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
   162
    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
   163
}
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
   164
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   165
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
   166
    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
   167
}
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
   168
22384
042ba96233f6 8029780: "ant externals" broke our test harness with the latest version of the octane benchmarks
lagergren
parents: 17777
diff changeset
   169
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
   170
    if (verbose) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   171
        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
   172
    }
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
function run_suite(tests, iters) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
    for (var idx = 0; idx < tests.length; idx++) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   177
        run_one_benchmark(tests[idx], iters);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
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
   182
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
if (typeof $ARGS !== 'undefined') {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
    args = $ARGS;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
} else if (typeof arguments !== 'undefined' && arguments.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
    args = arguments;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   187
}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
var new_args = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
for (i in args) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
    if (args[i].toString().indexOf(' ') != -1) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   192
        args[i] = args[i].replace(/\/$/, '');
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   193
        var s = args[i].split(' ');
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   194
        for (j in s) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   195
            new_args.push(s[j]);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   196
        }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
    } else {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   198
        new_args.push(args[i]);
16147
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
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   202
if (new_args.length != 0) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   203
    args = new_args;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   204
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   205
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   206
var tests_found = [];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   207
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
   208
var min_time = 5;
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   209
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   210
for (var i = 0; i < args.length; i++) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   211
    arg = args[i];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   212
    if (arg == "--iterations") {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   213
        iters = +args[++i];
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   214
        if (isNaN(iters)) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   215
            throw "'--iterations' must be followed by integer";
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   216
        }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   217
    } else if (arg == "--runtime") {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   218
        runtime = args[++i];
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   219
    } else if (arg == "--verbose") {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   220
        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
   221
    } else if (arg == "--min-time") {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   222
        min_time = +args[++i];
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   223
        if (isNaN(iters)) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   224
            throw "'--min-time' must be followed by integer";
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   225
        }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   226
    } else if (arg == "") {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   227
        continue; //skip
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   228
    } else {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   229
        var found = false;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   230
        for (j in tests) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   231
            if (tests[j].name === arg) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   232
                tests_found.push(tests[j]);
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   233
                found = true;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   234
                break;
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   235
            }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   236
        }
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   237
        if (!found) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   238
            var str = "unknown test name: '" + arg + "' -- valid names are: ";
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   239
            for (j in tests) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   240
                if (j != 0) {
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   241
                    str += ", ";
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   242
                }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   243
                str += "'" + tests[j].name + "'";
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   244
            }
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   245
            throw str;
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   246
        }
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   247
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   248
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   249
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   250
if (tests_found.length == 0) {
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   251
    for (i in tests) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   252
        tests_found.push(tests[i]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   253
    }
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 24767
diff changeset
   254
}
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   255
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
   256
// 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
   257
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
   258
    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
   259
}
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
   260
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
   261
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
   262
    try {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   263
        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
   264
    } catch (e) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   265
        print("ABORTING: Cannot find 'readFully'. You must have scripting enabled to use this test harness. (-scripting)");
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   266
        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
   267
    }
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
   268
}
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
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
   270
// 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
   271
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
   272
    if (a.name < b.name) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   273
        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
   274
    } else if (a.name > b.name) {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   275
        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
   276
    } else {
26980
381b7cf1729a 8059236: Memory leak when executing octane pdfjs with optimistic typing
hannesw
parents: 26768
diff changeset
   277
        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
   278
    }
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
   279
});
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   280
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
   281
load(path + 'base.js');
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   282
run_suite(tests_found, iters);