Sha256: 7cdb2ddb7eb3061099c91f30e82989a4bc6e5e98a2e78e33480e47fd11680f9a

Contents?: true

Size: 296 Bytes

Versions: 60

Compression:

Stored size: 296 Bytes

Contents

require 'benchmark'

TEST_AMOUNT = 1_000_000
Benchmark.bm(15) do |x|

  x.report('empty_array') do
    empty_array = []
    TEST_AMOUNT.times do
      empty_array.each{|e|}
    end
  end

  x.report('proc call') do
    block = proc {}
    TEST_AMOUNT.times do
      block.call
    end
  end

end

Version data entries

60 entries across 60 versions & 2 rubygems

Version Path
rack-app-11.0.2 spike/array_vs_proc.rb
rack-app-11.0.1 spike/array_vs_proc.rb
rack-app-11.0.0 spike/array_vs_proc.rb
rack-app-10.0.0 spike/array_vs_proc.rb
rack-app-9.0.0 spike/array_vs_proc.rb
rack-app-8.1.0 spike/array_vs_proc.rb
rack-app-8.0.1 spike/array_vs_proc.rb
rack-app-8.0.0 spike/array_vs_proc.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/spike/array_vs_proc.rb
rack-app-7.7.0 spike/array_vs_proc.rb
rack-app-7.6.5 spike/array_vs_proc.rb
rack-app-7.6.4 spike/array_vs_proc.rb
rack-app-7.6.3 spike/array_vs_proc.rb
rack-app-7.6.2 spike/array_vs_proc.rb
rack-app-7.6.1 spike/array_vs_proc.rb
rack-app-7.6.0 spike/array_vs_proc.rb
rack-app-7.5.2 spike/array_vs_proc.rb
rack-app-7.5.1 spike/array_vs_proc.rb
rack-app-7.5.0 spike/array_vs_proc.rb
rack-app-7.4.0 spike/array_vs_proc.rb