mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-05 21:24:45 +00:00
return function result in timeit decorator
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3297 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
1974bdcaf1
commit
e7107bc270
1 changed files with 8 additions and 3 deletions
|
|
@ -131,7 +131,7 @@ def notimplemented (func):
|
|||
return update_func_meta(newfunc, func)
|
||||
|
||||
|
||||
def timeit (func, log=sys.stderr):
|
||||
def timeit (func, log=sys.stderr, limit=2.0):
|
||||
"""
|
||||
Print execution time of the function. For quick'n'dirty profiling.
|
||||
"""
|
||||
|
|
@ -140,8 +140,13 @@ def timeit (func, log=sys.stderr):
|
|||
Execute function and print execution time.
|
||||
"""
|
||||
t = time.time()
|
||||
func(*args, **kwargs)
|
||||
print >> log, func.__name__, "took %0.2f seconds" % (time.time() - t)
|
||||
res = func(*args, **kwargs)
|
||||
duration = time.time() - t
|
||||
if duration > limit:
|
||||
print >> log, func.__name__, "took %0.2f seconds" % duration
|
||||
print >> log, args
|
||||
print >> log, kwargs
|
||||
return res
|
||||
return update_func_meta(newfunc, func)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue