Skip to content

Instantly share code, notes, and snippets.

@hiroyukim
Last active February 9, 2017 06:40
Show Gist options
  • Save hiroyukim/0c9db97221034eec92c30c45a6031c7e to your computer and use it in GitHub Desktop.
Save hiroyukim/0c9db97221034eec92c30c45a6031c7e to your computer and use it in GitHub Desktop.
require 'benchmark'
ary = []
ary2 = []
ary3 = []
Benchmark.bm 10 do |r|
r.report "+" do
10000.times { |n| ary += [n] }
end
r.report "push" do
10000.times { |n| ary2.push(n) }
end
r.report "<<" do
10000.times { |n| ary3 << n }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment