Sha256: 9e5a7d2be16b1eb3e0752305d374b2dfd7c661c1f407e260710cac16834158b3

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

#! /usr/bin/env ruby

lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'list'
require 'benchmark'

Benchmark.bm(32) do |x|
  [1000,10000,100000].each do |n|
    x.report("#{n}times") do
      n.times do
      end
    end
  end

  [Array, List].each do |obj|
    [1000,10000,100000].each do |n|
      x.report("#{obj}#new #{n}times") do
        n.times do
          obj.new
        end
      end
    end
  end

  [[:push, 1], [:unshift, 1], [:pop], [:shift], [:insert, 0, 1], [:delete_at, 0]].each do |args|
    m = args.shift
    [(0..100000).to_a, (0..100000).to_list].each do |obj|
      [1000,10000,100000].each do |n|
        o = obj.dup
        x.report("#{o.class}##{m} #{n}times") do
          n.times do
            o.send(m, *args)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
list-0.0.1 spec/bench.rb