Advertisement
nux95

benchmark decorator

May 7th, 2011
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. """
  2. Returns a tuple. The return of the function and the time it tookto execute.
  3. """
  4.  
  5. from time import time
  6.  
  7. def bench(f):
  8.     def nf(*args,**kwargs):
  9.         t = time()
  10.         r = f(*args,**kwargs)
  11.         t = time() - t
  12.         return r,t
  13.     nf.__name__ = f.__name__
  14.     return nf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement