
from functools import wraps
import time

# 函数运行计数装饰器
def timeit(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        start = time.perf_counter()
        result = func(*args, **kwargs)
        elapsed = time.perf_counter() - start
        print(f"函数 {func.__name__} 耗时: {elapsed:.4f}秒")
        return result
    return wrapper