Created
October 11, 2009 22:39
-
-
Save jcsalterego/207933 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $ time ruby test.rb && time ruby test2.rb | |
| real 0m0.358s | |
| user 0m0.270s | |
| sys 0m0.003s | |
| real 0m0.023s | |
| user 0m0.014s | |
| sys 0m0.002s |
This file contains hidden or 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
| words = [] | |
| 1..1000.times { |x| | |
| words << (["Mond", | |
| "abcdefghijklmnopqrstuvwxyz"[(x * 26) % 26, 1], | |
| "abcdefghijklmnopqrstuvwxyz"[x % 26, 1]].join("")) | |
| } | |
| re = Regexp.new(words.join("|") + "|Tuesday") | |
| 1..10000.times { |x| "Tuesday" =~ re } |
This file contains hidden or 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
| words = [] | |
| 1..1000.times { |x| | |
| words << (["abcdefghijklmnopqrstuvwxyz"[(x * 26) % 26, 1], | |
| "abcdefghijklmnopqrstuvwxyz"[x % 26, 1]].join("")) | |
| } | |
| re = Regexp.new("Mond(" + words.join("|") + ")|Tuesday") | |
| 1..10000.times { |x| "Tuesday" =~ re } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment