Benchmark multiple functions, with three different length int values.
()
| 164 | |
| 165 | |
| 166 | def benchmark() -> None: |
| 167 | """ |
| 168 | Benchmark multiple functions, with three different length int values. |
| 169 | """ |
| 170 | from collections.abc import Callable |
| 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): |
| 181 | benchmark_a_function(func, value) |
| 182 | print() |
| 183 | |
| 184 | |
| 185 | if __name__ == "__main__": |
no test coverage detected