Last active
June 13, 2020 05:04
-
-
Save evaneykelen/e965095ffcb40dcffda8a7ad2183bf40 to your computer and use it in GitHub Desktop.
benchmark
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' | |
array = File.readlines('dutch.bin') # 10k lines | |
Benchmark.bmbm do |x| | |
x.report { | |
x.report("tr") { array.each { |line| line.tr('e', 'z') } } | |
} | |
end | |
Benchmark.bmbm do |x| | |
x.report { | |
x.report("sub") { array.each { |line| line.sub('e', 'z') } } | |
} | |
end | |
Benchmark.bmbm do |x| | |
x.report { | |
x.report("gsub") { array.each { |line| line.gsub('e', 'z') } } | |
} | |
end |
Author
evaneykelen
commented
Jul 30, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment