-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (22 loc) · 790 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pi_montecarlo import estimate_pi, estimate_pi_np, estimate_pi_numba
import time
NUM_POINTS = 10_000_000
def main():
start = time.time()
pi = estimate_pi(NUM_POINTS)
end = time.time()
print(f"python estimation: {pi} took: {(end-start)}")
start = time.time()
pi = estimate_pi_np(NUM_POINTS)
end = time.time()
print(f"numpy estimation: {pi} took: {(end-start)}")
start = time.time()
pi = estimate_pi_numba(NUM_POINTS)
end = time.time()
print(f"python numba(with compilation) estimation: {pi} took: {(end-start)}")
start = time.time()
pi = estimate_pi_numba(NUM_POINTS)
end = time.time()
print(f"python numba(without compilation) estimation: {pi} took: {(end-start)}")
if __name__ == "__main__":
main()