MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / benchmark_a_function

Function benchmark_a_function

matrix/pascal_triangle.py:173–177  ·  view source on GitHub ↗
(func: Callable, value: int)

Source from the content-addressed store, hash-verified

171 from timeit import timeit
172
173 def benchmark_a_function(func: Callable, value: int) -> None:
174 call = f"{func.__name__}({value})"
175 timing = timeit(f"__main__.{call}", setup="import __main__")
176 # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
177 print(f"{call:38} -- {timing:.4f} seconds")
178
179 for value in range(15): # (1, 7, 14):
180 for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):

Callers 1

benchmarkFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected