This commit is contained in:
guanjihuan 2023-12-20 21:59:47 +08:00
parent 9c26a7ec96
commit d599ae945b
3 changed files with 27 additions and 10 deletions

View File

@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = guan
version = 0.1.64
version = 0.1.65
author = guanjihuan
author_email = guanjihuan@163.com
description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: guan
Version: 0.1.64
Version: 0.1.65
Summary: An open source python package
Home-page: https://py.guanjihuan.com
Author: guanjihuan

View File

@ -1,18 +1,35 @@
# 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
def wrapper(*args, **kwargs):
start = time.time()
result = func(*args, **kwargs)
end = time.time()
if time_type == 0:
print(f"Running time of {func.__name__}: {end - start} seconds")
elif time_type == 1:
print(f"Running time of {func.__name__}: {(end - start)/60} minutes")
elif time_type == 2:
print(f"Running time of {func.__name__}: {(end - start)/3600} hours")
print(f"Running time of {func.__name__}: {end - start} seconds")
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")
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")
return result
return wrapper