Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Created October 11, 2009 22:39
Show Gist options
  • Select an option

  • Save jcsalterego/207933 to your computer and use it in GitHub Desktop.

Select an option

Save jcsalterego/207933 to your computer and use it in GitHub Desktop.
$ 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
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 }
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