osdict_project/spider/normalutils/utils/timeit.py

15 lines
318 B
Python

from time import time
from functools import wraps
def timeit(func):
@wraps(func)
def _totime(*args, **kwargs):
st = time()
ans = func(*args, **kwargs)
end = time()
print("'{}' use time: {}".format(func.__name__, end - st))
return ans
return _totime