mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
15 lines
298 B
Ruby
15 lines
298 B
Ruby
|
require 'benchmark'
|
||
|
|
||
|
Benchmark.bm do |x|
|
||
|
[10_000,1_000_000,100_000_000].each do |n|
|
||
|
ary = Array.new(n,0)
|
||
|
GC.start
|
||
|
x.report("#{n}:shift"){ ary.shift }
|
||
|
(0..4).each do |i|
|
||
|
ary = Array.new(n,0)
|
||
|
GC.start
|
||
|
x.report("#{n}:shift(#{i})"){ ary.shift(i) }
|
||
|
end
|
||
|
end
|
||
|
end
|