Sha256: b8a58889097459df3f054cce9b58fdce7416807eacb975a4f4cabc31257e65ad

Contents?: true

Size: 338 Bytes

Versions: 126

Compression:

Stored size: 338 Bytes

Contents

require "benchmark"

STR1 = "Hello"
JOIN = "::"
STR2 = "World"

TESTS = 100_000
Benchmark.bmbm do |results|
  results.report("concat") { TESTS.times { "".concat(STR1).concat(JOIN).concat(STR2) } }
  results.report("add   ") { TESTS.times { STR1 + JOIN + STR2 } }
  results.report("join  ") { TESTS.times { [STR1, STR2].join(JOIN) } }
end

Version data entries

126 entries across 106 versions & 10 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/benchmarks/concat_vs_join.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/benchmarks/concat_vs_join.rb
yard-0.9.5 benchmarks/concat_vs_join.rb
yard-0.9.4 benchmarks/concat_vs_join.rb
yard-0.9.3 benchmarks/concat_vs_join.rb
yard-0.9.2 benchmarks/concat_vs_join.rb
yard-0.9.1 benchmarks/concat_vs_join.rb
yard-0.9.0 benchmarks/concat_vs_join.rb
yard-0.8.7.6 benchmarks/concat_vs_join.rb
yard-0.8.7.5 benchmarks/concat_vs_join.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
yard-0.8.7.4 benchmarks/concat_vs_join.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/benchmarks/concat_vs_join.rb