Created
March 18, 2014 17:23
-
-
Save knjname/9624823 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
| dupStr = (str, n) -> (str for _ in [1..n]).join('') | |
| testRegexp = (r, str, cnt) -> | |
| startTime = + new Date() | |
| for _ in [1..cnt] | |
| throw new Error("#{r} has matched!!") if str.match r | |
| finishTime = + new Date() | |
| finishTime - startTime | |
| tested_regexps = [/$^/, /^(?!.)./, /^(?!)/, /$a/, /$./, /(?!.)./, /(?!)/] | |
| for reg in tested_regexps | |
| document.write "<h2>About: #{reg}</h2>" | |
| for len in [0, 10000, 20000, 30000] | |
| str = dupStr('.', len) | |
| for repeated_count in [1000] | |
| document.write """ | |
| <p> | |
| length: #{ len }, | |
| repeated_count: #{ repeated_count }: | |
| <strong>#{ testRegexp reg, str, repeated_count }</strong> (msec) | |
| </p> | |
| """ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Referenced in this article: http://knjname.hateblo.jp/entry/2014/03/19/024810