ベンチマーク

多少、プログラムが動くようになったのでベンチマークを取ってみました。
Ruby, Io, PHP, Python, Lua, Java, Perl, Applescript, TCL, ELisp, Javascript, OCaml, Ghostscript, and C Fractal Benchmark - Timestretch
↑これをActiveScriptRuby1.8.637で実行した結果は、

Ruby Elapsed 9.172000

これに対し、IronRuby

IronRuby Elapsed 4.812

ってな感じでした。IronRubyの方がx2くらい速い結果となりました。あと、上記ベンチマークはそのままだとIronRubyでは動作しなかったので一部修正しています。ソースは以下の通り。

require "mscorlib"

BAILOUT = 16
MAX_ITERATIONS = 1000

class Mandelbrot
	
	def initialize
		puts "Rendering"
		for y in -39...39 do
			puts
			for x in -39...39 do
				i = iterate(x/40.0,y/40.0)
				if (i == 0)
					print "*"
				else
					print " "
				end
			end
		end
	end

	def iterate(x,y)
		cr = y-0.5
		ci = x
		zi = 0.0
		zr = 0.0
		i = 0
		
		while(1)
			i += 1
			temp = zr * zi
			zr2 = zr * zr
			zi2 = zi * zi
			zr = zr2 - zi2 + cr
			zi = temp + temp + ci
			return i if (zi2 + zr2 > BAILOUT)
			return 0 if (i > MAX_ITERATIONS)
		end
	
	end

end

time = System::DateTime.now
Mandelbrot.new
puts
span = System::DateTime.now.subtract time
print "IronRuby Elapsed ", span.seconds, ".", span.milliseconds