Created
October 12, 2012 12:09
-
-
Save jonleighton/3878907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark/ips' | |
| bar = 'bar' | |
| Benchmark.ips do |r| | |
| r.report('concatenation') { 'foo' << bar } | |
| r.report('interpolation') { "foo#{bar}" } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Calculating ------------------------------------- | |
| concatenation 45410 i/100ms | |
| interpolation 46498 i/100ms | |
| ------------------------------------------------- | |
| concatenation 1822091.6 (±9.9%) i/s - 9036590 in 5.011248s | |
| interpolation 1830436.5 (±10.4%) i/s - 9067110 in 5.010211s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar benchmark I made a few months ago. JRuby & Rubinius results are quite interesting.
https://gist.github.com/1707529