ruby-benchmarks/format-string/example.rb

16 lines
249 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'benchmark/ips'
value = 'value'
Benchmark.ips do |x|
x.time = 5
x.warmup = 0.5
x.report('format') { format('key:%s', value) }
x.report('#{}') { "key:#{value}" }
x.compare!
end