Thursday, July 16, 2009

IronRuby 0.6 and TofuHash

I took a quick look at IronRuby 0.6 which was release earlier this month. My first test of it was to run the TofuHash gem's unit tests.

Running in MRI (Matt's Ruby Interpreter) the result was:


Loaded suite test-tofuhash
Started
............................................................
Finished in 0.031 seconds.

60 tests, 220 assertions, 0 failures, 0 errors

.

Running in Iron Ruby the result was:


Loaded suite test-tofuhash
Started
...........................F.................F..............
Finished in 2.031315 seconds.

{stack traces for the failed cases removed to keep the output short}

60 tests, 220 assertions, 2 failures, 0 errors

.

The first thing to notice is the execution time difference 0.03 sec vs 2.03; which shows IronRuby still needs work on it's performance. These times are a good improvement over prior versions. Not show here is the start-up time. MRI was practically unnoticable, while IronRuby was noticable at ~5 seconds. The startup time is now fast enough to not be annoying.

The second noticable difference is that two tests failed under IronRuby.

The first was the #invert method. TofuHash doesn't have a custom implementation of #invert because in MRI's Hash #invert makes use of other methods in Hash. In IronRuby, it appears #invert has it's own implementation, so I'll have to give TofuHash a custom #invert to get that test to pass in IronRuby.

The second failed test was with YAML serialization and deserialization. I'll have to dig to find the root cause. Making a roundtrip from TofuHash to YAML and back, IronRuby resulted in a Hash object instead of a TofuHash. Just like the prior error, TofuHash doesn't have a custom implementation for #to_yaml, it just inherits it from Hash. I'm guessing there are differences between the implementations of Hash#to_yaml in MRI and IronRuby that work for Hash but dont work for the subclass TofuHash.

I'll probably wait until IronRuby 1.0 is released before updating TofuHash to correct these two errors. Until then, it appears TofuHash 1.0 will work in IronRuby 0.6 except for #invert and #to_yaml.

No comments: