Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 00748c013c5e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9968fcc72445
Choose a head ref

Commits on Oct 17, 2014

  1. [Truffle] Introduce LexicalScope to resolve constants.

    * Built during parsing, and completed with live modules when opening those.
    * No need for callingSelf except in the rare case of protected.
    * A few improvements on visbility checking.
    eregon committed Oct 17, 2014
    Copy the full SHA
    f25baf2 View commit details
  2. Copy the full SHA
    3b681af View commit details
  3. Copy the full SHA
    10be6ba View commit details
  4. Copy the full SHA
    5b6c7cf View commit details

Commits on Oct 18, 2014

  1. [Truffle] Document CoreMethod.onSingleton and isModuleFunction.

    * Fix usage of them in ThreadNodes.
    eregon committed Oct 18, 2014
    Copy the full SHA
    2a8dfe2 View commit details
  2. [Truffle] Fix typo.

    eregon committed Oct 18, 2014
    Copy the full SHA
    a03b018 View commit details

Commits on Oct 20, 2014

  1. Revert "[Truffle] Remove old benchmarks."

    This reverts commit 7a7365b.
    chrisseaton committed Oct 20, 2014
    Copy the full SHA
    781ebdd View commit details
  2. Copy the full SHA
    380de3b View commit details
  3. Copy the full SHA
    9640076 View commit details
  4. Copy the full SHA
    21d30da View commit details
  5. Copy the full SHA
    caf16a0 View commit details
  6. Copy the full SHA
    c141f0d View commit details
  7. Copy the full SHA
    6a34a20 View commit details
  8. Copy the full SHA
    4e3a4e2 View commit details
  9. Copy the full SHA
    9c391cf View commit details
  10. Copy the full SHA
    b11ff3f View commit details
  11. 2
    Copy the full SHA
    39f4e92 View commit details
  12. Nearly have IRScope removed from interpreter in attempt to promote In…

    …terpreterContext to top dog.
    
    Changed construction to pass in IRScope instead having insane param list
    enebo committed Oct 20, 2014
    Copy the full SHA
    e71749f View commit details
  13. Make ICs no longer be operands

    Clone WrappedIRClosure (mostly) now
    Simplify creation logic in IRClosure and IRScope with a single prepareForInterpretation.
    enebo committed Oct 20, 2014
    Copy the full SHA
    1134fe3 View commit details
  14. [Truffle] Dir#glob.

    chrisseaton committed Oct 20, 2014
    Copy the full SHA
    cd5a5ae View commit details
  15. Copy the full SHA
    df83810 View commit details
  16. [Truffle] File.read.

    chrisseaton committed Oct 20, 2014
    Copy the full SHA
    062573b View commit details
  17. Copy the full SHA
    859337d View commit details
  18. Copy the full SHA
    ee1d3d2 View commit details
  19. Copy the full SHA
    db76e6d View commit details
  20. Preserve update of currDynScope in interpreter loop.

    * When explicit call protocol instructions are present, currDynScope
      gets modified in the interpreter loop as part of push_binding
      instruction execution. This update should be preserved.
    subbuss committed Oct 20, 2014
    Copy the full SHA
    ac42880 View commit details
  21. Copy the full SHA
    93820f2 View commit details

Commits on Oct 21, 2014

  1. [Truffle] Fix Module#name.

    eregon committed Oct 21, 2014
    Copy the full SHA
    aa13f0c View commit details
  2. [Truffle] Fix most of constant lookup!

    * Use lexical scoping instead of pseudo-dynamic scoping.
    * Stop defining constants on singleton class, we define on the receiver only.
    * Temporarily disable the constant cache, we want better semantics first.
    eregon committed Oct 21, 2014
    Copy the full SHA
    286bee2 View commit details
  3. Copy the full SHA
    54be7dd View commit details
  4. Copy the full SHA
    002a256 View commit details
  5. Copy the full SHA
    f9292f3 View commit details
  6. Copy the full SHA
    5ccb89a View commit details
  7. Copy the full SHA
    4087b83 View commit details
  8. [Truffle] A few more specs in language/ are passing.

    * Also includes some fixes by the method lookup changes.
    eregon committed Oct 21, 2014
    Copy the full SHA
    9788867 View commit details
  9. [Truffle] Merge branch 'lexical_scope'

    * Constant cache is disabled for now.
    
    Conflicts:
    	core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
    	core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
    eregon committed Oct 21, 2014
    Copy the full SHA
    d673d88 View commit details
  10. Copy the full SHA
    c34c031 View commit details
  11. Appease subbu in making the intent between call protocol path seem mo…

    …re equal to non-call protocol path
    enebo committed Oct 21, 2014
    Copy the full SHA
    3b7d4a1 View commit details
  12. Copy the full SHA
    322767e View commit details
  13. IC pushed further through stack

    enebo committed Oct 21, 2014
    Copy the full SHA
    bc28e1c View commit details
  14. Moving interpreter logic into Interpreter (for now). IRScriptBody.int…

    …erpret moved into Intepreter.
    
    New ScriptBodyInterpreterContext to store begin and end blocks (shared with scope currently).
    
    Removed some dead code and parameters.
    enebo committed Oct 21, 2014
    Copy the full SHA
    eafe2d7 View commit details
  15. Remove wonky name check to compensate for module/class bodies sharing…

    … InterpretedIRMethod.
    
    Possibly provide state for real synthetic methods when we add them.
    enebo committed Oct 21, 2014
    Copy the full SHA
    de35267 View commit details
  16. Copy the full SHA
    b8f9bcb View commit details
  17. Copy the full SHA
    d84dadb View commit details
  18. Copy the full SHA
    9968fcc View commit details
Showing with 4,520 additions and 903 deletions.
  1. +1 −0 bench/truffle/.gitignore
  2. +100 −0 bench/truffle/binary-trees.rb
  3. +2 −0 bench/truffle/c/Makefile
  4. +151 −0 bench/truffle/c/mandelbrot.c
  5. +137 −0 bench/truffle/compare.rb
  6. +729 −0 bench/truffle/deltablue.rb
  7. +111 −0 bench/truffle/fannkuch-redux.rb
  8. +80 −0 bench/truffle/harness.rb
  9. +143 −0 bench/truffle/java/Mandelbrot.java
  10. +137 −0 bench/truffle/js/mandelbrot.js
  11. +18 −0 bench/truffle/lib/deterministic-random.rb
  12. +121 −0 bench/truffle/mandelbrot-kernel-loop.rb
  13. +112 −0 bench/truffle/mandelbrot.rb
  14. +207 −0 bench/truffle/n-body-dynamic.rb
  15. +188 −0 bench/truffle/n-body.rb
  16. +189 −0 bench/truffle/neural-net.rb
  17. +88 −0 bench/truffle/pidigits.rb
  18. +25 −0 bench/truffle/report/all.gnuplot
  19. +25 −0 bench/truffle/report/almost-all.gnuplot
  20. +25 −0 bench/truffle/report/competition.gnuplot
  21. +25 −0 bench/truffle/report/interpreters.gnuplot
  22. +25 −0 bench/truffle/report/jruby.gnuplot
  23. +25 −0 bench/truffle/report/other-vms.gnuplot
  24. +25 −0 bench/truffle/report/rbx.gnuplot
  25. +294 −0 bench/truffle/report/report.rb
  26. +25 −0 bench/truffle/report/summary.gnuplot
  27. +25 −0 bench/truffle/report/topaz.gnuplot
  28. +401 −0 bench/truffle/richards.rb
  29. +95 −0 bench/truffle/spectral-norm.rb
  30. +1 −2 core/src/main/java/org/jruby/Ruby.java
  31. +2 −2 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRMetaClassBody.java
  32. +26 −15 core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRMethod.java
  33. +1 −1 core/src/main/java/org/jruby/ir/Compiler.java
  34. +2 −2 core/src/main/java/org/jruby/ir/IRBuilder.java
  35. +7 −22 core/src/main/java/org/jruby/ir/IRClosure.java
  36. +4 −1 core/src/main/java/org/jruby/ir/IREvalScript.java
  37. +8 −5 core/src/main/java/org/jruby/ir/IRScope.java
  38. +9 −64 core/src/main/java/org/jruby/ir/IRScriptBody.java
  39. +4 −9 core/src/main/java/org/jruby/ir/IRTranslator.java
  40. +1 −1 core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java
  41. +24 −0 core/src/main/java/org/jruby/ir/interpreter/ClosureInterpreterContext.java
  42. +83 −62 core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
  43. +134 −0 core/src/main/java/org/jruby/ir/interpreter/InterpreterContext.java
  44. +29 −0 core/src/main/java/org/jruby/ir/interpreter/ScriptBodyInterpreterContext.java
  45. +0 −49 core/src/main/java/org/jruby/ir/operands/ClosureInterpreterContext.java
  46. +0 −93 core/src/main/java/org/jruby/ir/operands/InterpreterContext.java
  47. +5 −10 core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
  48. +1 −1 core/src/main/java/org/jruby/ir/persistence/IRReader.java
  49. +2 −2 core/src/main/java/org/jruby/runtime/InterpretedIRBlockBody.java
  50. +38 −2 core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
  51. +20 −11 core/src/main/java/org/jruby/truffle/nodes/ReadConstantNode.java
  52. +2 −1 core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
  53. +5 −0 core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  54. +2 −0 core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
  55. +12 −5 core/src/main/java/org/jruby/truffle/nodes/WriteConstantNode.java
  56. +2 −2 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  57. +11 −4 core/src/main/java/org/jruby/truffle/nodes/core/BasicObjectNodes.java
  58. +9 −0 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethod.java
  59. +11 −75 core/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
  60. +55 −54 core/src/main/java/org/jruby/truffle/nodes/core/DirNodes.java
  61. +28 −0 core/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
  62. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  63. +19 −9 core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  64. +1 −1 core/src/main/java/org/jruby/truffle/nodes/core/SystemNode.java
  65. +3 −3 core/src/main/java/org/jruby/truffle/nodes/core/ThreadNodes.java
  66. +1 −39 core/src/main/java/org/jruby/truffle/nodes/core/TruffleDebugNodes.java
  67. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBooleanDispatchNode.java
  68. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedDispatchNode.java
  69. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedMethodMissingDispatchNode.java
  70. +6 −5 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedReturnMissingDispatchNode.java
  71. +5 −4 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedSymbolDispatchNode.java
  72. +2 −1 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedDispatchNode.java
  73. +7 −6 core/src/main/java/org/jruby/truffle/nodes/dispatch/CachedUnboxedDispatchNode.java
  74. +6 −6 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchHeadNode.java
  75. +10 −23 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchNode.java
  76. +19 −12 core/src/main/java/org/jruby/truffle/nodes/dispatch/GenericDispatchNode.java
  77. +52 −48 core/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
  78. +3 −0 core/src/main/java/org/jruby/truffle/nodes/methods/MethodDefinitionNode.java
  79. +8 −9 core/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetClassNode.java
  80. +8 −9 core/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetModuleNode.java
  81. +41 −0 core/src/main/java/org/jruby/truffle/nodes/objects/LexicalScopeNode.java
  82. +3 −0 core/src/main/java/org/jruby/truffle/nodes/objects/OpenModuleNode.java
  83. +2 −1 core/src/main/java/org/jruby/truffle/nodes/supercall/AbstractGeneralSuperCallNode.java
  84. +43 −0 core/src/main/java/org/jruby/truffle/runtime/LexicalScope.java
  85. +21 −14 core/src/main/java/org/jruby/truffle/runtime/ModuleOperations.java
  86. +27 −0 core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  87. +10 −2 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  88. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  89. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubyClass.java
  90. +9 −54 core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
  91. +1 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java
  92. +4 −21 core/src/main/java/org/jruby/truffle/runtime/methods/RubyMethod.java
  93. +16 −1 core/src/main/java/org/jruby/truffle/runtime/methods/SharedMethodInfo.java
  94. +1 −1 core/src/main/java/org/jruby/truffle/runtime/subsystems/FeatureManager.java
  95. +97 −58 core/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  96. +1 −24 core/src/main/java/org/jruby/truffle/translator/ModuleTranslator.java
  97. +3 −4 core/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  98. +0 −1 spec/truffle/tags/language/class_tags.txt
  99. +0 −20 spec/truffle/tags/language/constants_tags.txt
  100. +0 −4 spec/truffle/tags/language/defined_tags.txt
  101. +1 −5 spec/truffle/tags/language/metaclass_tags.txt
  102. +1 −0 spec/truffle/tags/language/module_tags.txt
  103. +0 −1 spec/truffle/tags/language/send_tags.txt
  104. +1 −3 spec/truffle/tags/language/singleton_class_tags.txt
1 change: 1 addition & 0 deletions bench/truffle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reference.data
100 changes: 100 additions & 0 deletions bench/truffle/binary-trees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright © 2004-2013 Brent Fulgham
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of "The Computer Language Benchmarks Game" nor the name
# of "The Computer Language Shootout Benchmarks" nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# The Computer Language Benchmarks Game
# http://benchmarksgame.alioth.debian.org
#
# contributed by Jesse Millikan
# Modified by Wesley Moxam

# http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees&lang=yarv&id=1

def item_check(left, item, right)
return item if left.nil?
item + item_check(*left) - item_check(*right)
end

def bottom_up_tree(item, depth)
return [nil, item, nil] unless depth > 0
item_item = 2 * item
depth -= 1
[bottom_up_tree(item_item - 1, depth), item, bottom_up_tree(item_item, depth)]
end

def binary_trees(max_depth)
sum = 0

min_depth = 4

max_depth = min_depth + 2 if min_depth + 2 > max_depth

stretch_depth = max_depth + 1
stretch_tree = bottom_up_tree(0, stretch_depth)

sum += item_check(*stretch_tree)
stretch_tree = nil

long_lived_tree = bottom_up_tree(0, max_depth)

min_depth.step(max_depth + 1, 2) do |depth|
iterations = 2**(max_depth - depth + min_depth)

check = 0

for i in 1..iterations
temp_tree = bottom_up_tree(i, depth)
check += item_check(*temp_tree)

temp_tree = bottom_up_tree(-i, depth)
check += item_check(*temp_tree)
end

sum += depth
sum += check
end

sum += item_check(*long_lived_tree)

sum
end

def warmup
1000.times do
binary_trees(10)
end
end

def sample
binary_trees(15) == -87308
end

def name
return "shootout-binary-trees"
end
2 changes: 2 additions & 0 deletions bench/truffle/c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mandelbrot: mandelbrot.c
$(CC) -std=c99 -O3 -o $@ $^
151 changes: 151 additions & 0 deletions bench/truffle/c/mandelbrot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// Copyright © 2004-2013 Brent Fulgham
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of "The Computer Language Benchmarks Game" nor the name
// of "The Computer Language Shootout Benchmarks" nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org
//
// contributed by Karl von Laudermann
// modified by Jeremy Echols
// modified by Detlef Reichl
// modified by Joseph LaFata
// modified by Peter Zotov

// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=yarv&id=3

#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>

int mandelbrot(double size) {
int sum = 0;

int byte_acc = 0;
int bit_num = 0;

int y = 0;
while (y < size) {
double ci = (2.0*y/size)-1.0;

int x = 0;
while (x < size) {
double zr = 0.0;
double zrzr = zr;
double zi = 0.0;
double zizi = zi;
double cr = (2.0*x/size)-1.5;
int escape = 1;

int z = 0;
while (z < 50) {
double tr = zrzr - zizi + cr;
double ti = 2.0*zr*zi + ci;
zr = tr;
zi = ti;
// preserve recalculation
zrzr = zr*zr;
zizi = zi*zi;
if (zrzr+zizi > 4.0) {
escape = 0;
break;
}
z += 1;
}

byte_acc = (byte_acc << 1) | escape;
bit_num += 1;

// Code is very similar for these cases, but using separate blocks
// ensures we skip the shifting when it's unnecessary, which is most cases.
if (bit_num == 8) {
//print byte_acc.chr
sum ^= byte_acc;
byte_acc = 0;
bit_num = 0;
} else if (x == size - 1) {
byte_acc <<= (8 - bit_num);
//print byte_acc.chr
sum ^= byte_acc;
byte_acc = 0;
bit_num = 0;
}
x += 1;
}
y += 1;
}

return sum;
}

void warmup() {
for (int n = 0; n < 10000; n++) {
mandelbrot(10);
}
}

int sample() {
return mandelbrot(750) == 192;
}

double secondtime();

int main(int argc, char** argv) {
int budget = atoi(argv[0]);

warmup();

int iterations = 0;

double start = secondtime();
double elapsed;

while (1) {
if (!sample()) {
abort();
}

iterations++;

elapsed = secondtime() - start;

if (elapsed > budget)
break;
}

double score = iterations / elapsed * 1000.0;

printf("%f\n", score);
}

double secondtime() {
// Not monotonic
struct timeval t;
gettimeofday(&t, NULL);
return t.tv_sec + t.tv_usec / 1e6;
}
137 changes: 137 additions & 0 deletions bench/truffle/compare.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

time_budget = nil
reference = false
verbose = false

args = ARGV.dup

while not args.empty?
arg = args.shift

case arg
when "--reference"
reference = true
when "-s"
time_budget = args.shift.to_i
when "-m"
time_budget = args.shift.to_i * 60
when "-h"
time_budget = args.shift.to_i * 60 * 60
when "-v"
verbose = true
when "--help", "-help", "-h"
puts "Note: use a system Ruby to run this script, not the development JRuby, as that seems to sometimes get in a twist"
puts
puts "Set a reference point, running for 5 minutes:"
puts " JAVACMD=... ruby benchmark-compare.rb --reference -m 5"
puts
puts "Compare against that reference point:"
puts " JAVACMD=... ruby benchmark-compare.rb"
puts
puts " -s n run for n seconds (default 60)"
puts " -m n run for n minutes"
puts " -h n run for n hours"
puts
puts " -v show all output"
exit
else
puts "unknown argument " + arg
exit
end
end

if reference
if time_budget.nil?
time_budget = 60
end
else
reference_scores = {}

if not time_budget.nil?
puts "can't specify budget unless --reference"
exit
end

File.open("reference.data").each do |line|
key, value = line.split
if key == "-s"
time_budget = value.to_i
else
reference_scores[key] = value.to_f
end
end
end

if ENV["JAVACMD"].nil? or not File.exist? File.expand_path(ENV["JAVACMD"])
puts "warning: couldn't find $JAVACMD - set this to the path of the Java command in graalvm-jdk1.8.0 or a build of the Graal repo"
end

benchmarks = [
"binary-trees",
"fannkuch-redux",
"mandelbrot",
"n-body",
"pidigits",
"spectral-norm",
"neural-net",
"richards",
#"deltablue"
]

disable_splitting = [
"spectral-norm",
"neural-net"
]

time_budget_per_run = time_budget / benchmarks.length
puts time_budget_per_run.to_s + "s for each benchmark" if reference

scores = {}

benchmarks.each do |benchmark|
if disable_splitting.include? benchmark
splitting = "-J-G:-TruffleSplitting"
else
splitting = ""
end

output = `../../bin/jruby -J-server #{splitting} -X+T harness.rb -s #{time_budget_per_run} #{benchmark}.rb`
score_match = /[a-z\-]+: (\d+\.\d+)/.match(output)
if score_match.nil?
score = 0
puts benchmark + " error"
puts output
else
if verbose
puts output
end

score = score_match[1].to_f
puts benchmark + " " + score.to_s
end
scores[benchmark] = score
end

if reference
File.open("reference.data", "w") do |file|
file.write("-s #{time_budget}\n")

benchmarks.each do |benchmark|
file.write("#{benchmark} #{scores[benchmark]}\n")
end
end
else
puts "-------"
benchmarks.each do |benchmark|
increase = scores[benchmark] - reference_scores[benchmark]
increase_percentage = increase / reference_scores[benchmark] * 100
puts "#{benchmark.ljust(15)} #{increase_percentage.round(2).to_s.rjust(6)}%"
end
end
Loading