Created
October 31, 2012 00:34
-
-
Save JoshTGreenwood/3984074 to your computer and use it in GitHub Desktop.
Benchmark strip vs. chomp in ruby
This file contains 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' | |
Benchmark.bmbm do |x| | |
x.report("Stripping /n with String.strip") { 100_000.times {"filename.rb\n".strip} } | |
x.report("Stripping /n with String.chomp") { 100_000.times {"filename.rb\n".chomp} } | |
end |
This file contains 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
Rehearsal ------------------------------------------------------------------ | |
Stripping /n with String.strip 0.040000 0.000000 0.040000 ( 0.035811) | |
Stripping /n with String.chomp 0.030000 0.000000 0.030000 ( 0.033354) | |
--------------------------------------------------------- total: 0.070000sec | |
user system total real | |
Stripping /n with String.strip 0.040000 0.000000 0.040000 ( 0.035512) | |
Stripping /n with String.chomp 0.030000 0.000000 0.030000 ( 0.034136) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment