Actions
Bug #13354
closedImprove Time#<=> performance
Bug #13354:
Improve Time#<=> performance
Description
Time#<=> will be faster around 60%.
If internal values would have Fixnum,
optimized function improves performance.
(https://github.com/ruby/ruby/blob/9b69e9fafc329aaa540d5adeb55124f020abfe3c/time.c#L57-L67)
Before¶
After¶
Test code¶
require 'benchmark'
Benchmark.bmbm do |x|
x.report do
t1 = Time.now
t2 = Time.now
10000000.times do
t1 <=> t2
end
end
end
Patch¶
The patch is in https://github.com/ruby/ruby/pull/1546
Actions