Created
June 11, 2014 06:38
-
-
Save ugisozols/6cb08668e7aaf5df7516 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
Rehearsal ---------------------------------------------------- | |
split/map/reject 0.060000 0.000000 0.060000 ( 0.064907) | |
scan with regex 0.030000 0.000000 0.030000 ( 0.024250) | |
------------------------------------------- total: 0.090000sec | |
user system total real | |
split/map/reject 0.070000 0.000000 0.070000 ( 0.068857) | |
scan with regex 0.020000 0.000000 0.020000 ( 0.023608) |
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" | |
str = "\n \t\tab 09:09 \t\t\n \t\tan 10:57 \t" | |
n = 10000 | |
Benchmark.bmbm do |x| | |
x.report("split/map/reject") do | |
n.times do | |
str.split(/\t/).map(&:strip).reject(&:empty?) | |
end | |
end | |
x.report("scan with regex") do | |
n.times do | |
str.scan(/\d{2}:\d{2}/) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment