range.c (range_min): use OPTIMIZED_CMP() to compare the objects instead of
`<=>' method dispatching for Fixnum/Float/String object inside Range object.
range.c (range_max): ditto.
Range#min -> 34 % up
Range#max -> 44 % up
[ruby-core:80713] [Bug #13443] [Fix GH-1585]
Improve performance of Range#{min,max}
range.c (range_min): use OPTIMIZED_CMP() to compare the objects instead of
`<=>' method dispatching for Fixnum/Float/String object inside Range object.
range.c (range_max): ditto.
Before¶
After¶
Test code¶
require 'benchmark/ips'
Benchmark.ips do |x|
x.report "Range#min" do |i|
i.times { (1..100).min }
end
x.report "Range#max" do |i|
i.times { (1..100).max }
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e