Last active
May 10, 2023 10:44
-
-
Save alxgsv/185273ae9f9ed245d537c8c5d26d32b5 to your computer and use it in GitHub Desktop.
Ruby array += vs <<
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby test.rb | |
40.268058 | |
0.046918 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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