From d599ae945bd583288d6056d768be2f4fed6c0b10 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Wed, 20 Dec 2023 21:59:47 +0800 Subject: [PATCH] 0.1.65 --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan/__init__.py | 33 +++++++++++++++++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 36279a0..85bb6ad 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -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 diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 0d22c63..bcbe605 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -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 diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index c98e50d..d90b52f 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -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