Python, Python Programming, Programming, Coding, Artificial Intelligence.
second Now, let’s add a decorator to time this or any function: def time_function(func): def wrapper(*args, **kwargs): start = time.perf_counter() result = func(*args, **kwargs) end = time.perf_counter() print(f"{func.__name__} took {end - start:.6f} seconds") return result return wrapper