Skip to content

Instantly share code, notes, and snippets.

@knjname
Created March 18, 2014 17:23
Show Gist options
  • Select an option

  • Save knjname/9624823 to your computer and use it in GitHub Desktop.

Select an option

Save knjname/9624823 to your computer and use it in GitHub Desktop.
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>
"""
@knjname
Copy link
Copy Markdown
Author

knjname commented Mar 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment