0.1.65
This commit is contained in:
parent
9c26a7ec96
commit
d599ae945b
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.1.64
|
version = 0.1.65
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.1.64
|
Version: 0.1.65
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
@ -1,17 +1,34 @@
|
|||||||
# Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about (Ji-Huan Guan, 关济寰). The primary location of this package is on website https://py.guanjihuan.com. The GitHub location of this package is on https://github.com/guanjihuan/py.guanjihuan.com.
|
# Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about (Ji-Huan Guan, 关济寰). The primary location of this package is on website https://py.guanjihuan.com. The GitHub location of this package is on https://github.com/guanjihuan/py.guanjihuan.com.
|
||||||
|
|
||||||
# 函数的装饰器,用于获取计算时间
|
# 函数的装饰器,用于获取计算时间(秒)
|
||||||
def timer_decorator(func, time_type=0):
|
def timer_decorator(func):
|
||||||
import time
|
import time
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
end = time.time()
|
end = time.time()
|
||||||
if time_type == 0:
|
|
||||||
print(f"Running time of {func.__name__}: {end - start} seconds")
|
print(f"Running time of {func.__name__}: {end - start} seconds")
|
||||||
elif time_type == 1:
|
return result
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
# 函数的装饰器,用于获取计算时间(分)
|
||||||
|
def timer_decorator_minutes(func):
|
||||||
|
import time
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
start = time.time()
|
||||||
|
result = func(*args, **kwargs)
|
||||||
|
end = time.time()
|
||||||
print(f"Running time of {func.__name__}: {(end - start)/60} minutes")
|
print(f"Running time of {func.__name__}: {(end - start)/60} minutes")
|
||||||
elif time_type == 2:
|
return result
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
# 函数的装饰器,用于获取计算时间(时)
|
||||||
|
def timer_decorator_hours(func):
|
||||||
|
import time
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
start = time.time()
|
||||||
|
result = func(*args, **kwargs)
|
||||||
|
end = time.time()
|
||||||
print(f"Running time of {func.__name__}: {(end - start)/3600} hours")
|
print(f"Running time of {func.__name__}: {(end - start)/3600} hours")
|
||||||
return result
|
return result
|
||||||
return wrapper
|
return wrapper
|
||||||
|
Loading…
x
Reference in New Issue
Block a user