Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
require 'benchmark/ips'
ARRAY = [*1..100]
def fast
ARRAY[-1]
end
def slow
ARRAY.last
end
Benchmark.ips do |x|
x.report('Array#[-1]') { fast }
x.report('Array#last') { slow }
x.compare!
end