X-Combinator

Avatar

making the human scalable

String interpolation is faster than printf in Ruby

Just wanted to make a note, string interpolation is faster than printf in Ruby. Example:

$ irb
>> require 'benchmark'
=> true
>> Benchmark.measure { 100000.times {
  "%s" % ["hello world"] } }.total
=> 0.21
>> Benchmark.measure { 100000.times {
  "#{'hello world'}"} }.total
=> 0.04
del.icio.us:String interpolation is faster than printf in Ruby digg:String interpolation is faster than printf in Ruby reddit:String interpolation is faster than printf in Ruby

No Comments, Comment or Ping

Reply to “String interpolation is faster than printf in Ruby”