Archived
添加了计时器装饰器
This commit is contained in:
1 file changed
+2
-2
+2
-2
@@ -12,11 +12,11 @@ from functools import wraps
|
|||||||
def time_it(func):
|
def time_it(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
print('数据库文件开始下载')
|
print('I: 数据库文件开始下载')
|
||||||
start = time.time()
|
start = time.time()
|
||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
end = time.time()
|
end = time.time()
|
||||||
print('下载结束, 耗时 {} 秒'.format(round(end - start, 2)))
|
print('I: 下载结束, 耗时 {} 秒'.format(round(end - start, 2)))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user