MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / time_func

Function time_func

maths/fibonacci.py:26–37  ·  view source on GitHub ↗

Times the execution of a function with parameters

(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

24
25
26def time_func(func, *args, **kwargs):
27 """
28 Times the execution of a function with parameters
29 """
30 start = time()
31 output = func(*args, **kwargs)
32 end = time()
33 if int(end - start) > 0:
34 print(f"{func.__name__} runtime: {(end - start):0.4f} s")
35 else:
36 print(f"{func.__name__} runtime: {(end - start) * 1000:0.4f} ms")
37 return output
38
39
40def fib_iterative_yield(n: int) -> Iterator[int]:

Callers 1

fibonacci.pyFile · 0.85

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected