I am trying to use timeit to get the run time of one of the function in the with two arguments, but I keep getting error: cannot import name make_heap() class queueHeap(): def make_heap(self, alist): i = len(alist)//2 self.currentSize = len(alist) self.heapList = [0] + alist[:] while (i > 0): self.swapDown(i) i = i - 1
for num in range(1, 100, 10) :
L = []
binaryHeap = queueHeap()
for i in range(1, num):
randomElement = random.randint(1, 100)
L.append(randomElement)
time_MakeHeap = timeit.Timer('make_heap(self, L)', 'from __main__ import make_heap, self, L')
print("n=%s: %s" % (num, time_MakeHeap.timeit(1)))