test/script/basic/run-octane.js

changeset 963
e2497b11a021
parent 962
ac62e33a99b0
child 1028
d79265f2fa92
     1.1 --- a/test/script/basic/run-octane.js	Wed Aug 20 10:25:28 2014 +0200
     1.2 +++ b/test/script/basic/run-octane.js	Wed Aug 20 10:26:01 2014 +0200
     1.3 @@ -24,31 +24,10 @@
     1.4  /**
     1.5   * @subtest
     1.6   */
     1.7 +var payload = __DIR__ + "octane-payload.js";
     1.8 +load(payload);
     1.9  
    1.10 -var tests = [
    1.11 -    {name:"box2d",         files:["box2d.js"],                         suite:"Box2DBenchmark"},
    1.12 -    {name:"code-load",     files:["code-load.js"],                     suite:"CodeLoad"},
    1.13 -    {name:"crypto",        files:["crypto.js"],                        suite:"Crypto"},
    1.14 -    {name:"deltablue",     files:["deltablue.js"],                     suite:"DeltaBlue"},
    1.15 -    {name:"earley-boyer",  files:["earley-boyer.js"],                  suite:"EarleyBoyer"},
    1.16 -    {name:"gbemu",         files:["gbemu-part1.js", "gbemu-part2.js"], suite:"GameboyBenchmark"},
    1.17 -    {name:"mandreel",      files:["mandreel.js"],                      suite:"MandreelBenchmark"},
    1.18 -    {name:"navier-stokes", files:["navier-stokes.js"],                 suite:"NavierStokes"},
    1.19 -    {name:"pdfjs",         files:["pdfjs.js"],                         suite:"PdfJS"},
    1.20 -    {name:"raytrace",      files:["raytrace.js"],                      suite:"RayTrace"},
    1.21 -    {name:"regexp",        files:["regexp.js"],                        suite:"RegExpSuite"},
    1.22 -    {name:"richards",      files:["richards.js"],                      suite:"Richards"},
    1.23 -    {name:"splay",         files:["splay.js"],                         suite:"Splay"},
    1.24 -    {name:"typescript",    files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"}
    1.25 -    //zlib currently disabled - requires read
    1.26 -    //    {name:"zlib",          files:["zlib.js", "zlib-data.js"], suite:"zlib"},
    1.27 -];
    1.28 -var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
    1.29 -
    1.30 -// TODO: why is this path hard coded when it's defined in project properties?
    1.31 -var path = dir + "../external/octane/";
    1.32 -
    1.33 -var runtime = "";
    1.34 +var runtime = undefined;
    1.35  var verbose = false;
    1.36  
    1.37  var numberOfIterations = 5;
    1.38 @@ -79,6 +58,10 @@
    1.39      load(file_name);
    1.40      }
    1.41  
    1.42 +    if (typeof arg.before !== 'undefined') {
    1.43 +    arg.before();
    1.44 +    }
    1.45 +
    1.46      if (compile_and_return) {
    1.47      print_always(arg, "Compiled OK");
    1.48      }
    1.49 @@ -86,6 +69,7 @@
    1.50  
    1.51  }
    1.52  
    1.53 +
    1.54  function run_one_benchmark(arg, iters) {
    1.55  
    1.56      if (!load_bench(arg)) {
    1.57 @@ -114,7 +98,7 @@
    1.58          benchmarks[x].Setup();
    1.59      }
    1.60      BenchmarkSuite.ResetRNG();
    1.61 -    print_verbose(arg, "running '" + arg.name + "' for " + iters + " iterations of no less than " + min_time + " seconds (" + runtime + ")");
    1.62 +    print_verbose(arg, "running '" + arg.name + "' for " + iters + " iterations of no less than " + min_time + " seconds");
    1.63  
    1.64      var scores = [];
    1.65  
    1.66 @@ -153,9 +137,11 @@
    1.67          max_score = Math.max(max_score, scores[x]);
    1.68      }
    1.69      mean_score /= iters;
    1.70 -
    1.71      } catch (e) {
    1.72 -    print_always("*** Aborted and setting score to zero. Reason: " + e);
    1.73 +    print_always(arg, "*** Aborted and setting score to zero. Reason: " + e);
    1.74 +    if (e instanceof java.lang.Throwable) {
    1.75 +        e.printStackTrace();
    1.76 +    }
    1.77      mean_score = min_score = max_score = 0;
    1.78      scores = [0];
    1.79      }
    1.80 @@ -167,8 +153,12 @@
    1.81      print_always(arg, res);
    1.82  }
    1.83  
    1.84 +function runtime_string() {
    1.85 +    return runtime == undefined ? "" : ("[" + runtime + "] ");
    1.86 +}
    1.87 +
    1.88  function print_always(arg, x) {
    1.89 -    print("[" + arg.name + "] " + x);
    1.90 +    print(runtime_string() + "[" + arg.name + "] " + x);
    1.91  }
    1.92  
    1.93  function print_verbose(arg, x) {
    1.94 @@ -183,8 +173,6 @@
    1.95      }
    1.96  }
    1.97  
    1.98 -runtime = "command line";
    1.99 -
   1.100  var args = [];
   1.101  
   1.102  if (typeof $ARGS !== 'undefined') {
   1.103 @@ -218,12 +206,18 @@
   1.104      arg = args[i];
   1.105      if (arg == "--iterations") {
   1.106      iters = +args[++i];
   1.107 +    if (isNaN(iters)) {
   1.108 +        throw "'--iterations' must be followed by integer";
   1.109 +    }
   1.110      } else if (arg == "--runtime") {
   1.111      runtime = args[++i];
   1.112      } else if (arg == "--verbose") {
   1.113      verbose = true;
   1.114      } else if (arg == "--min-time") {
   1.115      min_time = +args[++i];
   1.116 +    if (isNaN(iters)) {
   1.117 +        throw "'--min-time' must be followed by integer";
   1.118 +    }
   1.119      } else if (arg == "") {
   1.120      continue; //skip
   1.121      } else {
   1.122 @@ -254,10 +248,30 @@
   1.123      }
   1.124  }
   1.125  
   1.126 -tests_found.sort();
   1.127 +// returns false for rhino, v8 and all other javascript runtimes, true for Nashorn
   1.128 +function is_this_nashorn() {
   1.129 +    return typeof Error.dumpStack == 'function'
   1.130 +}
   1.131 +
   1.132 +if (is_this_nashorn()) {
   1.133 +    try {
   1.134 +    read = readFully;
   1.135 +    } catch (e) {
   1.136 +    print("ABORTING: Cannot find 'readFully'. You must have scripting enabled to use this test harness. (-scripting)");
   1.137 +    throw e;
   1.138 +    }
   1.139 +}
   1.140 +
   1.141 +// run tests in alphabetical order by name
   1.142 +tests_found.sort(function(a, b) {
   1.143 +    if (a.name < b.name) {
   1.144 +    return -1;
   1.145 +    } else if (a.name > b.name) {
   1.146 +    return 1;
   1.147 +    } else {
   1.148 +    return 0;
   1.149 +    }
   1.150 +});
   1.151  
   1.152  load(path + 'base.js');
   1.153  run_suite(tests_found, iters);
   1.154 -
   1.155 -
   1.156 -

mercurial