Skip to content

Instantly share code, notes, and snippets.

@alxgsv
Last active May 10, 2023 10:44
Show Gist options
  • Save alxgsv/185273ae9f9ed245d537c8c5d26d32b5 to your computer and use it in GitHub Desktop.
Save alxgsv/185273ae9f9ed245d537c8c5d26d32b5 to your computer and use it in GitHub Desktop.
Ruby array += vs <<
$ ruby test.rb
40.268058
0.046918
interactions = 100_000
a = Time.now
contents = []
interactions.times do |i|
contents += [i.to_s, i.to_s]
end
puts Time.now - a
a = Time.now
contents = []
interactions.times do |i|
contents << i.to_s
contents << i.to_s
end
puts Time.now - a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment