Actions
Bug #13354
closedImprove 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¶
user system total real
1.410000 0.000000 1.410000 ( 1.407848)
After¶
user system total real
0.880000 0.000000 0.880000 ( 0.886662)
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
Like0
Like0