Skip to content

Commit 30aabe7

Browse files
committed
Add performance benchmark
1 parent 09a44fd commit 30aabe7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

project_euler/problem_073/sol1.py

+15
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ def solution(max_d: int = 12_000) -> int:
7171
fractions_number += 1
7272
return fractions_number
7373

74+
def benchmark() -> None:
75+
"""
76+
Benchmarks
77+
"""
78+
# Running performance benchmarks...
79+
# slow_solution : 21.02750190000006
80+
# solution : 15.79036830000041
81+
82+
from timeit import timeit
83+
84+
print("Running performance benchmarks...")
85+
86+
print(f"slow_solution : {timeit('slow_solution()', globals=globals(), number=10)}")
87+
print(f"solution : {timeit('solution()', globals=globals(), number=10)}")
7488

7589
if __name__ == "__main__":
7690
print(f"{solution() = }")
91+
benchmark()

0 commit comments

Comments
 (0)