Archive of December 2010

ruby GP performance pt.2

And with ruby 1.9.2p0

sammael:rubyGP greay$ time ruby tinyGP.rb 

real    0m12.546s
user    0m11.819s
sys 0m0.631s

MacRuby definitely seems to be the winner here...


ruby GP performance

I really haven't done much any performance tuning, but MY GOD.

sammael:rubyGP greay$ time ruby tinyGP.rb

real    0m26.821s
user    0m25.995s
sys 0m0.647s
sammael:rubyGP greay$ time java tiny_gp 23 sin-data.txt 

real    0m0.495s
user    0m0.658s
sys 0m0.074s
sammael:rubyGP greay$ time macruby tinyGP.rb 

real    0m1.199s
user    0m1.369s
sys 0m0.045s

This is just creating a population of 10000 individuals; nothing fancy. using OS X's builtin (I think; I may have upgraded) ruby - MRI ruby 1.8.7, to be exact, that's 26 seconds. Any amount of tuning I could throw at it, I don't think I could get it down to the original java implementation's < 0.5 seconds. Even if I'm doing something completely braindead, that's a nearly 60x difference.

So I decided to try out MacRuby. I heard it's better; it's based on 1.9 and has a whole bunch of exciting things about it. LLVM! Integration w/the objective C runtime! And it's fast! ~ 1.2 seconds! That's waaaay better than the original ruby run, and it's the exact same code. It's still 3x slower than the java implementation, but like I said, I've done little to no tuning yet. But I'm happy w/3x slower for the time being... I want to play around w/the code a bit before I bother making it faster.


ruby GP

I recently started reading A Field Guide to Genetic Programming ... Barely in to it at all yet, but I've decided to rewrite the sample code (TinyGP) in Ruby. Because I like Ruby better than Java.

It's very short. And the (very rough) ruby implementation w/o much anything special done to it is quite a bit shorter – down from 12KB to 8, and I really didn't take anything out. That's just the extra cruft that Java requires. For all I know the ruby implementation is orders of magnitude slower, though, I don't know. Hell, I've barely tested it so I don't even know it works.

The code's @ github.