Add format vs interpolation

This commit is contained in:
Loic Nageleisen 2023-04-26 11:59:23 +02:00
parent f42114b16a
commit cf3a374bf4
Signed by: lloeki
GPG key ID: D05DAEE6889F94C2
2 changed files with 28 additions and 0 deletions

16
format-string/example.rb Executable file
View file

@ -0,0 +1,16 @@
#!/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