Skip to content

Instantly share code, notes, and snippets.

@RoxasShadow
Created September 11, 2013 09:34
Show Gist options
  • Select an option

  • Save RoxasShadow/6521389 to your computer and use it in GitHub Desktop.

Select an option

Save RoxasShadow/6521389 to your computer and use it in GitHub Desktop.
require 'benchmark'
time = Benchmark.realtime do
puts [].tap { |ary|
1000.times { |i|
ary << i
}
}.length
end
puts "Time elapsed #{time*1000} milliseconds"
time = Benchmark.realtime do
ary = []
1000.times { |i|
ary << i
}
puts ary.length
end
puts "Time elapsed #{time*1000} milliseconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment