Skip to content

Instantly share code, notes, and snippets.

@cypher
Created September 16, 2009 20:37
Show Gist options
  • Save cypher/188179 to your computer and use it in GitHub Desktop.
Save cypher/188179 to your computer and use it in GitHub Desktop.
Yup. Ich weiss das Fibonacci als Benchmark selbst bestenfalls nur bedingt geeignet ist, aber dieses Programm:
def fib(n)
if (n < 2)
n
else
fib(n-1) + fib(n-2)
end
end
puts fib(35)
hat folgende Laufzeiten (MacRuby ist die akutellste Trunk-Version):
eschaton :: ~ » ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin9.8.0]
eschaton :: ~ » time ruby benchmark.rb
9227465
ruby benchmark.rb 4.56s user 0.04s system 98% cpu 4.686 total
eschaton :: ~ » macruby -v
MacRuby version 0.5 (ruby 1.9.0) [universal-darwin10.0, x86_64]
eschaton :: ~ » time macruby benchmark.rb
9227465
macruby benchmark.rb 0.59s user 0.03s system 95% cpu 0.650 total
eschaton :: ~ » macrubyc -o benchmark benchmark.rb
eschaton :: ~ » time ./benchmark
9227465
./benchmark 0.45s user 0.02s system 89% cpu 0.529 total
Zum Spass hab ich auf fib(50) erhöht, und das ist dabei rausgekommen:
eschaton :: ~ » macrubyc -o benchmark benchmark.rb && time ./benchmark
102334155
./benchmark 4.52s user 0.04s system 96% cpu 4.705 total
eschaton :: ~ » time macruby benchmark.rb
102334155
macruby benchmark.rb 5.89s user 0.08s system 93% cpu 6.375 total
eschaton :: ~ » time ruby benchmark.rb
102334155
ruby benchmark.rb 48.37s user 0.34s system 97% cpu 49.842 total
Ich glaube das gibt dir schon eine gute Idee wie viel schneller MacRuby mit LLVM sein kann.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment