Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- n = 2000
- Benchmark.bmbm do |x|
- x.report('+=') {
- num = rand.to_s[0..10] * 100
- c = ""
- n.times { c += num }
- }
- x.report('<<') {
- num = rand.to_s[0..10] * 100
- c = ""
- n.times { c << num }
- }
- x.report('#{}'){
- num = rand.to_s[0..10] * 100
- c = ""
- n.times { c = "#{c}#{num}" }
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement