benchmark.rb
```ruby
#!/usr/bin/ruby
require "benchmark/ips"
a = []
Benchmark.ips do |x|
x.report("push") do |times|
i = 0
a.clear
while (i += 1) < times
a.push(1, 2, 3)
end
end
x.report("concat") do |times|
i = 0
a.clear
while (i += 1) < times
a.concat([1, 2, 3])
end
end
x.compare!
end
```
I've seen a few place where people are
concat
ing array literals, which could have beenpush
ed instead:
```ruby #!/usr/bin/ruby require "benchmark/ips" a = [] Benchmark.ips do |x| x.report("push") do |times| i = 0 a.clear while (i += 1) < times a.push(1, 2, 3) end end x.report("concat") do |times| i = 0 a.clear while (i += 1) < times a.concat([1, 2, 3]) end end x.compare! end ```benchmark.rb