Created
April 1, 2015 12:38
-
-
Save anonymous/3ae651fbd3cbb0b74118 to your computer and use it in GitHub Desktop.
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
Calculating ------------------------------------- | |
#gsub 19583 i/100ms | |
#gsub! 18808 i/100ms | |
------------------------------------------------- | |
#gsub 299922.0 (±4.6%) i/s - 1507891 in 5.038274s | |
#gsub! 281888.2 (±3.9%) i/s - 1410600 in 5.011569s | |
Comparison: | |
#gsub: 299922.0 i/s | |
#gsub!: 281888.2 i/s - 1.06x slower |
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/ips' | |
Benchmark.ips do |bench| | |
bench.config(time: 5, warmup: 2) | |
bench.report("#gsub") do | |
unused = "literalstring".gsub(/era/,'o') | |
end | |
bench.report("#gsub!") do | |
unused = "literalstring".gsub!(/era/,'o') | |
end | |
bench.compare! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment