Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

16 lines (12 sloc) 256 Bytes
require 'benchmark/ips'
Benchmark.ips do |x|
x.report('Array#unshift') do
array = []
100_000.times { |i| array.unshift(i) }
end
x.report('Array#insert') do
array = []
100_000.times { |i| array.insert(0, i) }
end
x.compare!
end
You can’t perform that action at this time.