>>534
# gem install benchmark_driver
require 'benchmark_driver'

Benchmark.driver do |x|
x.prelude %{ input = (1..2_000_000).to_a.shuffle
RUBY
x.report 'push without size', %{o = []; input.each{|x| o.push x }}
x.report '[]= with size (each_with_index)', %{o = Array.new(input.size); input.each_with_index{|x,ix| o[ix] = x }}
x.report '[]= with size (each)', %{o = Array.new(input.size); i=0; input.each{|x| o[i] = x;i+=1 }}
x.report 'block with size', %{o = Array.new(input.size){|x| input[x] }}
end