Skip to content

Instantly share code, notes, and snippets.

@goodniceweb
goodniceweb / benchmark_prefix_for_string.rb
Created August 14, 2015 12:29
Gist shows benchmark code for adding prefix to string in Ruby
require "benchmark/ips"
def use_array_join
str = "world"
prefix = "Hello, "
[prefix, str].join # => "Hello, world"
end
def use_insert
str = "world"