0.1.65
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user