Last active
October 19, 2016 21:06
-
-
Save epitron/3101dfc5384706c8e58f862cf1f9f493 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
require 'epitools' | |
str = "asdlfkjasGdlCfjasdflkjsafAjkhweDrkjThawerlkajhsdfkljhasdfACTG"* 10000 | |
bench( | |
tr: proc{ str.tr('^ACTG', '') }, | |
gsub: proc{ str.gsub(/[^ACTG]+/, '') }, | |
gsub2: proc{ str.gsub(/[^ACTG]/, '') }, | |
scan: proc{ str.scan(/[ACTG]/).join }, | |
scan2: proc{ str.scan(/[ACTG]+/).join } | |
) | |
# ============== | |
# OUTPUT: | |
# ============== | |
# | |
# * Benchmarking 100 iterations... | |
# user system total real | |
# tr 0.060000 0.000000 0.060000 ( 0.067188) | |
# gsub 1.390000 0.010000 1.400000 ( 1.397851) | |
# gsub2 7.040000 0.000000 7.040000 ( 7.035661) | |
# scan 2.060000 0.000000 2.060000 ( 2.054325) | |
# scan2 1.840000 0.000000 1.840000 ( 1.834801) |
havenwood
commented
Oct 19, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment