On Tue, Aug 25, 2009 at 5:20 PM, Nathan Keel[email protected] wrote:
Groovy 1.6.3
http://mastrodonato.info/index.php/2009/08/comparison-script-languages-for-the-fractal-geometry/?lang=en
A decent try and honest, but there are too many variables involved.
… Don’t get me wrong, I appreciate what you’re doing here and it’s
a good attempt, I just think there are too many variables…
you might offer something in C and C++ to compare to compiled Java,
unless you believe that those aren’t viable comparison languages for
some reason?
OpenJDK Client VM (build 14.0-b08, mixed mode, sharing)
java Bench1 > /dev/null
Java Elapsed 0.08
Java Elapsed 0.079
Java Elapsed 0.079
ruby 1.9.2dev (2009-08-25 trunk 24642) [i686-linux]
ruby bench1.rb > /dev/null
Ruby Elapsed 3.515
Ruby Elapsed 3.352
Ruby Elapsed 3.523
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (OpenJDK Client VM
1.6.0_0) [i386-java]
jruby bench1.rb > /dev/null
Ruby Elapsed 4.185
Ruby Elapsed 3.760
Ruby Elapsed 3.626
ruby 1.9.2dev (2009-08-25 trunk 24642) [i686-linux]
ruby -rubygems bench2.rb > /dev/null
Ruby Elapsed 0.059
Ruby Elapsed 0.058
Ruby Elapsed 0.060
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (OpenJDK Client VM
1.6.0_0) [i386-java]
jruby -rubygems bench2.rb > /dev/null
Ruby Elapsed 0.409
Ruby Elapsed 0.410
Ruby Elapsed 0.412
require ‘ffi-inliner’
BAILOUT = 16
MAX_ITERATIONS = 1000
class Bench2
extend Inliner
def initialize
puts “Rendering…”
for y in -39…39
for x in -39…39
print iterate(x/40.0, y/40.0) == 0 ? “*” : " "
end
print “\n”
end
end
inline <<-EO
int n;
int iterate(double x, double y)
{
int i = 0;
double zi = 0.0;
double zr = 0.0;
double zi2, zr2, temp;
double ci = x;
double cr = y-0.5;
while(i < #{MAX_ITERATIONS}) {
i++;
temp = zr * zi;
zr2 = zr * zr;
zi2 = zi * zi;
zr = zr2 - zi2 + cr;
zi = temp + temp + ci;
if(zi2 + zr2 > #{BAILOUT}) return i;
}
return 0;
}
EO
end
time = Time.now
Bench2.new
STDERR.puts “Ruby Elapsed %.3f” % (Time.now - time)
In this case, the original Ruby version of the method looked so much
like C that I don’t think you lose much in readability by inlining
(except for loss of vim’s syntax highlighting).