From: brabuhr@... Date: 2009-08-26T07:18:36+09:00 Subject: Re: Comparison Ruby, Python, Php, Groovy ecc. On Tue, Aug 25, 2009 at 5:20 PM, Nathan Keel wrote: > Marco Mastrodonato wrote: >> Comparison script languages for the fractal geometry, these are the >> languages i tested: >> >> Java >> Lua 5.1.4 >> Php 5.3.0 >> Python 2.6.2 >> Python 3.1.1 >> Jython 2.5.0 >> Groovy 1.6.3 >> Jruby 1.3.1 >> Ruby 1.9.1 p129 >> Ruby 1.8.6 p368 >> Ruby 1.8.6 p111 >> IronRuby 0.9.0 >> IronPython 2.0.2 >> Perl 5.10.0 >> >> Let me know yours comment >> >> 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).