some execution time testings

This commit is contained in:
Stefan Harmuth 2022-01-17 09:40:02 +01:00
parent cdac29dee7
commit f700f0cb32

View File

@ -3,24 +3,9 @@ from tools.trees import MinHeap, BinarySearchTree
from tools.stopwatch import StopWatch from tools.stopwatch import StopWatch
b = BinarySearchTree()
for x in range(16):
b.add(x)
b.print()
print("---")
b.remove(7)
b.remove(6)
b.remove(4)
b.remove(5)
b.print()
exit()
# timing below :'-(
s = StopWatch() s = StopWatch()
h = [] h = []
for x in range(10_000): for x in range(1_000_000):
heappush(h, x) heappush(h, x)
print("Heappush:", s.elapsed()) print("Heappush:", s.elapsed())
while h: while h:
@ -29,7 +14,7 @@ print("Heappop:", s.elapsed())
s = StopWatch() s = StopWatch()
h = MinHeap() h = MinHeap()
for x in range(10_000): for x in range(1_000_000):
h.add(x) h.add(x)
print("MinHeap.add():", s.elapsed()) print("MinHeap.add():", s.elapsed())
while not h.empty(): while not h.empty():