Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created May 1, 2014 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsodmike/a167f35acb78e2aad625 to your computer and use it in GitHub Desktop.
Save bsodmike/a167f35acb78e2aad625 to your computer and use it in GitHub Desktop.
Performance hit with string interpolation in Ruby
require 'benchmark'
puts Benchmark.measure { 500_000.times { '5' } }
puts Benchmark.measure { 500_000.times { "#{5}" } }
Program Output
0.070000 0.000000 0.070000 ( 0.075135)
0.140000 0.000000 0.140000 ( 0.133944)
OK (0.244 sec real, 0.253 sec wall, 9 MB, 61 syscalls)
@bsodmike
Copy link
Author

bsodmike commented May 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment