Last active
April 27, 2016 19:43
-
-
Save headius/8328831 to your computer and use it in GitHub Desktop.
mandelbrot performance across JRuby 9k modes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# interpreted AST | |
system ~/projects/jruby $ jruby.bash -X-C mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
4.862 | |
4.822 | |
4.822 | |
4.846 | |
5.057 | |
5.018 | |
4.827 | |
4.864 | |
4.876 | |
4.858 | |
4.863 | |
4.83 | |
4.81 | |
4.832 | |
4.873 | |
4.883 | |
4.888 | |
4.871 | |
4.85 | |
4.831 | |
# interpreted IR | |
system ~/projects/jruby $ jruby.bash -X-CIR mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
5.199 | |
5.118 | |
5.091 | |
5.115 | |
5.056 | |
5.124 | |
5.041 | |
5.003 | |
5.029 | |
5.013 | |
4.983 | |
5.011 | |
5.013 | |
5.025 | |
5.07 | |
5.022 | |
4.995 | |
5.031 | |
5.012 | |
4.992 | |
# Compiled AST, no invokedynamic | |
system ~/projects/jruby $ jruby.bash -Xcompile.invokedynamic=false mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
0.732 | |
0.745 | |
0.715 | |
0.73 | |
0.72 | |
0.726 | |
0.739 | |
0.746 | |
0.792 | |
0.817 | |
0.82 | |
0.823 | |
0.814 | |
0.78 | |
0.723 | |
0.727 | |
0.745 | |
0.723 | |
0.746 | |
0.724 | |
# Compiled AST, with invokedynamic | |
system ~/projects/jruby $ jruby.bash mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
0.597 | |
0.601 | |
0.611 | |
0.602 | |
0.606 | |
0.588 | |
0.605 | |
0.593 | |
0.609 | |
0.6 | |
0.59 | |
0.61 | |
0.614 | |
0.598 | |
0.605 | |
0.591 | |
0.61 | |
0.593 | |
0.596 | |
0.589 | |
# Compiled IR, with invokedynamic | |
system ~/projects/jruby $ jruby.bash -X+CIR mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
2.171 | |
0.722 | |
0.708 | |
0.697 | |
0.704 | |
0.692 | |
0.706 | |
0.702 | |
0.698 | |
0.694 | |
0.695 | |
0.689 | |
0.704 | |
0.703 | |
0.702 | |
0.698 | |
0.697 | |
0.719 | |
0.708 | |
0.692 | |
# Interpreted IR with unboxing (no boxing guards) | |
system ~/projects/jruby $ jruby.bash -X-CIR -Xir.unboxing=true mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
2.454 | |
2.459 | |
2.393 | |
2.377 | |
2.39 | |
2.46 | |
2.385 | |
2.373 | |
2.393 | |
2.399 | |
2.449 | |
2.568 | |
2.726 | |
2.395 | |
2.407 | |
2.438 | |
2.384 | |
2.387 | |
2.4 | |
2.479 | |
# Compiled IR, with invokedynamic and unboxing (without boxing guards) | |
system ~/projects/jruby $ jruby.bash -X+CIR -Xir.unboxing=true mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
0.565 | |
0.312 | |
0.097 | |
0.098 | |
0.104 | |
0.097 | |
0.097 | |
0.106 | |
0.108 | |
0.097 | |
0.114 | |
0.102 | |
0.098 | |
0.095 | |
0.094 | |
0.096 | |
0.096 | |
0.097 | |
0.097 | |
0.095 | |
# Truffle AST interpreter without Graal JIT | |
system ~/projects/jruby $ jruby.bash -Xtruffle mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
21.662 | |
21.815 | |
22.059 | |
22.247 | |
21.903 | |
22.222 | |
22.228 | |
21.854 | |
21.997 | |
22.368 | |
22.665 | |
22.632 | |
22.125 | |
21.986 | |
21.941 | |
22.508 | |
22.049 | |
22.547 | |
24.453 | |
25.782 | |
# Truffle AST interpreter plus Graal JIT | |
system ~/projects/jruby $ jruby.bash -Xtruffle mandelbrot.rb 20 | |
warming up | |
[truffle] optimized Method mandelbrot_foo:(name):1@10e41621 34aa3427 |Nodes 332 |Time 2169(1630+540 )ms |Nodes 717/ 1105 |CodeSize 7696 | |
running mandelbrot(500) for 20 iterations | |
0.048 | |
0.048 | |
0.048 | |
0.046 | |
0.048 | |
0.047 | |
0.048 | |
0.048 | |
0.047 | |
0.047 | |
0.047 | |
0.048 | |
0.047 | |
0.046 | |
0.053 | |
0.048 | |
0.048 | |
0.048 | |
0.05 | |
0.049 | |
system ~/projects/jruby $ ../rubinius/bin/rbx mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
1.777457 | |
1.813019 | |
1.823906 | |
1.8459219999999998 | |
1.776521 | |
1.798789 | |
1.80667 | |
1.8231220000000001 | |
2.018687 | |
1.982492 | |
1.832832 | |
1.808677 | |
1.810901 | |
1.8509929999999999 | |
1.828273 | |
1.818692 | |
1.8148900000000001 | |
1.786165 | |
1.780102 | |
1.776106 | |
system ~/projects/jruby $ rvm ruby-2.1 do ruby mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
1.864769 | |
1.863214 | |
1.856388 | |
1.854244 | |
1.847911 | |
1.89504 | |
1.898902 | |
1.851657 | |
1.843574 | |
1.866589 | |
1.886925 | |
1.87296 | |
1.846614 | |
1.86955 | |
1.848435 | |
1.921733 | |
1.841216 | |
1.856 | |
1.85546 | |
1.877311 | |
system ~/projects/jruby $ ../topaz/bin/topaz mandelbrot.rb 20 | |
warming up | |
running mandelbrot(500) for 20 iterations | |
0.0593700408936 | |
0.0568559169769 | |
0.0556919574738 | |
0.0560510158539 | |
0.0551681518555 | |
0.0552649497986 | |
0.0546820163727 | |
0.0579178333282 | |
0.0544011592865 | |
0.0559079647064 | |
0.0561909675598 | |
0.0547771453857 | |
0.0551559925079 | |
0.0554881095886 | |
0.0549249649048 | |
0.0552458763123 | |
0.0564270019531 | |
0.0546000003815 | |
0.0535879135132 | |
0.0573658943176 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mandelbrot_foo(size) | |
#puts "P4\n#{size} #{size}" | |
iter = 50 | |
limit = 2.0 | |
byte_acc = 0 | |
bit_num = 0 | |
y = 0 | |
while (y < size) do | |
x = 0 | |
while (x < size) do | |
zr = 0.0 | |
zi = 0.0 | |
cr = (2.0*x/size)-1.5 | |
ci = (2.0*y/size)-1.0 | |
escape = false | |
i = 0 | |
while (i < iter) do | |
tr = zr*zr - zi*zi + cr | |
ti = 2*zr*zi + ci | |
zr, zi = tr, ti | |
if (zr*zr+zi*zi) > (limit*limit) | |
escape = true | |
break | |
end | |
i += 1 | |
end | |
byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1) | |
bit_num += 1 | |
if (bit_num == 8) || (x == size - 1) | |
byte_acc <<= (8 - bit_num) | |
#print byte_acc.chr | |
byte_acc = 0 | |
bit_num = 0 | |
end | |
x += 1 | |
end | |
y += 1 | |
end | |
end | |
puts "warming up" | |
10000.times { | |
mandelbrot_foo(10) | |
} | |
times = (ARGV[0] || 10).to_i | |
m = (ARGV[1] || 500).to_i | |
puts "running mandelbrot(" + m.to_s + ") for " + times.to_s + " iterations" | |
i = 0 | |
while i < times | |
t = Time.now | |
mandelbrot_foo(m) | |
puts Time.now - t | |
i+=1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I didn't expect topaz to be so close. Good job i guess.