From fc14b72e69fb722ed384f6d3f0ea4a23a6071015 Mon Sep 17 00:00:00 2001 From: SnowindMe <1945743455@qq.com> Date: Sat, 12 Apr 2025 22:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E4=B8=8B=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E8=A7=A3=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/utils/timer_calculater.py | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/plugins/utils/timer_calculater.py b/src/plugins/utils/timer_calculater.py index c3020bd08..8fbb98728 100644 --- a/src/plugins/utils/timer_calculater.py +++ b/src/plugins/utils/timer_calculater.py @@ -3,6 +3,38 @@ from functools import wraps from typing import Optional, Dict, Callable import asyncio +""" +# 更好的计时器 +感谢D指导 + +# 用法: + +- +@Timer() +def func(): + pass + +- +time_dict = {} +@Timer("计数", time_dict) +def func(): + pass + +- +def func(): + with Timer() as t: + pass + +- +def func(): + time_dict = {} + with Timer("计数", time_dict) as t: + pass + +属性:human_readable +自定义错误:TimerTypeError +""" + class TimerTypeError(TypeError): """自定义类型错误"""