-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (30 loc) · 1007 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
from heap import Heap
from plot import plot_result
import random
import time
import gc
def main():
gc.disable()
test_case = random.sample(range(300000), 100000)
probes = [i * 10000 for i in range(1, 11)]
creation_times = []
remove_top_times = []
for branch in [2, 5, 7]:
case = []
case2 = []
for k in range(10):
start = time.time()
Heap(list=test_case[:k*10000], branches=branch)
case.append(float(round(time.time() - start, 4)))
creation_times.append(case)
heap = Heap(list=test_case, branches=branch)
start = time.time()
for k in range(100000):
heap.remove_top()
if k % 10000 == 0:
case2.append(time.time() - start)
remove_top_times.append(case2)
plot_result(probes=probes, times=creation_times, operation="create")
plot_result(probes=probes, times=remove_top_times, operation="remove top")
if __name__ == "__main__":
main()