Benchmarks
()
| 140 | |
| 141 | |
| 142 | def benchmark() -> None: |
| 143 | """ |
| 144 | Benchmarks |
| 145 | """ |
| 146 | # Running performance benchmarks... |
| 147 | # slow_solution : 108.50874730000032 |
| 148 | # while_sol : 28.09581200000048 |
| 149 | # solution : 25.063097400000515 |
| 150 | |
| 151 | from timeit import timeit |
| 152 | |
| 153 | print("Running performance benchmarks...") |
| 154 | |
| 155 | print(f"slow_solution : {timeit('slow_solution()', globals=globals(), number=10)}") |
| 156 | print(f"while_sol : {timeit('while_solution()', globals=globals(), number=10)}") |
| 157 | print(f"solution : {timeit('solution()', globals=globals(), number=10)}") |
| 158 | |
| 159 | |
| 160 | if __name__ == "__main__": |