I discovered one problem with performance of the equals operator in the RubyComparable class.
To have a picture what I have , please check a performance of the following commands:
As you see, when objects of different types are being compared, performance is way lower.
After running following command:
It turned out, that there are is some exception being thrown, and, but it doesn't show up in the ruby console, as e.g. for the '>' or '>=' operators.
After I looked into the code, I have a feeling, that it's not needed to raise the ArgumentError, since it's not being shown in the ruby console.
Currently, this exception is being caught, and the returnValueOnError variable is being returned. Can this behavior be changed? I think the returnValueOnError value can be returned immediately, in case when the comparison value is nil.
Is there any other reason (which I could have missed) for raising the exception is needed for this operator?
Please see my pull request with possible solution for this problem: -
After switching to the code with my fix, please run again the performance tests listed above. It should do the comparison much faster.