Skip to content

Instantly share code, notes, and snippets.

@flopezluis
Created December 17, 2013 18:03

Revisions

  1. flopezluis created this gist Dec 17, 2013.
    11 changes: 11 additions & 0 deletions timeit.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    import timeit
    def catastrophic(n):
    pat = re.compile('([a|b]+)+c')
    text = "%s" %('a' * n)
    pat.search(text)

    from functools import partial
    for i in range(100):
    cata = partial(catastrophic, i)
    print "The function lasted: %f" %timeit.timeit(cata, number=1)