Issue Type: Improvement Improvement
Affects Versions: JRuby 1.6.7
Assignee: Unassigned
Components: Performance
Created: 02/Oct/12 7:08 AM
Description:

Hi,

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:

require 'benchmark'
b = Time.now
print Benchmark.measure { 10000.times { Time.now == '' } }.inspect + "\n"
print Benchmark.measure { 10000.times { Time.now == b } }.inspect + "\n"

As you see, when objects of different types are being compared, performance is way lower.

After running following command:

jruby -d -Xbacktrace.style=raw -J-Djruby.log.backtraces=true -e'print Time.now == ""'

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: -FIXME-
After switching to the code with my fix, please run again the performance tests listed above. It should do the comparison much faster.

Best,
Kamil.

Environment: Ubuntu, Java 1.6
Project: JRuby
Priority: Minor Minor
Reporter: Kamil Bednarz
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to