I couldn't resist writing an equivalent program that runs on the Mono
VM:-)
Very interesting. While we don't compete with typed languages, its nice to see, that parrot execution speed is in the region of mono - for such small tight loops.
My *guess* is that mono executes the same code faster because of better
register allocation and faster function calls,
Register allocation AFAIK. PMCs are not in registers yet (only I- and N-Regs). I dunno on which architecture you ran the test, but FYI JIT/i386 calls vtable functions directly for simple opcodes like add. If we have finally PMCs in registers too, we could safe more cycles...
... I expect parrot to improve on both counts as it matures, at least as long as the vtable functions are implemented in C: anyone with performance numbers for vtable functions implemented in parrot asm?
We don't have methods yet.
Hope this helps in the discussion (I included the C# code below so that people can check if I missed something of the semantics).
A little thing is missing in your code: if num+num gives an equivalent int, it should get morphed back to a PerlIV.
lupus
Thanks for that comparison, leo