Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Created December 21, 2013 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpringMT/8068584 to your computer and use it in GitHub Desktop.
Save SpringMT/8068584 to your computer and use it in GitHub Desktop.
sample scriptarray_push_vs_arrows.rb
#!/usr/bin/env ruby
require 'benchmark'
n = 1000000
array = []
Benchmark.bm(7, ">total:", ">ave:") do |x|
a = x.report("push") { n.times{ array.push 1 } }
b = x.report("<<") { n.times{ array << 1 } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment