Guest User

Untitled

a guest
Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. require "benchmark"
  2.  
  3. STR1 = "Hello"
  4. JOIN = "::"
  5. STR2 = "World"
  6.  
  7. TESTS = 100_000
  8. Benchmark.bmbm do |results|
  9. results.report("concat") { TESTS.times { "".concat(STR1).concat(JOIN).concat(STR2) } }
  10. results.report("add ") { TESTS.times { STR1 + JOIN + STR2 } }
  11. results.report("join ") { TESTS.times { [STR1, STR2].join(JOIN) } }
  12. end
Add Comment
Please, Sign In to add comment