Ruby comparisons benchmark

October 5, 2011

I recently had to make a huge loop faster (about 10 milllion iterations). The loop spent quite some time checking the state of an object, so I benchmarked some different comparisons in Ruby, on different ruby implementations (Rubinius 2.0.0 pre, MRI 1.9.2-p290 and REE-1.8.7)


Between implementations:

I might switch from string comparison to symbol (or constant integer) comparison in heavy loops.

NOTE: Benches were run on a 2011 MacBook Pro 2.66 Ghz Core i7.

Discussion, links, and tweets

I work at Venture Spirit. Follow me on Twitter; you'll enjoy my tweets. I take care to carefully craft each one. Or at least aim to make you giggle. Or offended. One of those two— I haven't decided which yet.