summaryrefslogtreecommitdiff
path: root/benchmark/array_shift.rb
blob: 798bb9e3f4017655b238d0a94abe810fcf49cee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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