Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (13 sloc) 254 Bytes
require 'benchmark/ips'
ARRAY = (1..100).to_a
def slow
ARRAY.reverse.each{|x| x}
end
def fast
ARRAY.reverse_each{|x| x}
end
Benchmark.ips do |x|
x.report('Array#reverse.each') { slow }
x.report('Array#reverse_each') { fast }
x.compare!
end
You can’t perform that action at this time.