Sha256: a3a42d2e205a666e6a9f06cf14830180e069f44f34b8857646cbe4289aca4630

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

require 'benchmark'
require_relative '../../lib/hyper_iterator'
$stdout.sync = true

puts
puts '----------------- Array#each! -----------------'
puts '#i    user      system      total       real'

base_arr = Array.new(10000) { '-' * 10 }
arrs = [base_arr]

i = 0
while true
  print "#{i} "
  arr = []
  report = Benchmark.measure do
    arrs[i].each! { |el| arr << el.dup }

    # Try to use this line and see how many more iterations you can get
    # Remember to uncomment line#24 as well.
    # You need to pop the array so the reference goes away.
    # arrs[0].each! { |el| arr << el.dup }
  end

  # Uncomment this to use with the above line#22
  # arrs.pop

  puts report
  arrs << arr
  i += 1
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hyper_iterator-0.3.1 benchmark/memory_bm/each_bang.rb
hyper_iterator-0.3.0 benchmark/memory_bm/each_bang.rb
hyper_iterator-0.2.2 benchmark/memory_bm/each_bang.rb
hyper_iterator-0.2.1 benchmark/memory_bm/each_bang.rb
hyper_iterator-0.2.0 benchmark/memory_bm/each_bang.rb