-
Notifications
You must be signed in to change notification settings - Fork 10
/
Comparison_queue.py
33 lines (25 loc) · 965 Bytes
/
Comparison_queue.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
from ArrayQueue import ArrayQueue
from LoopQueue import LoopQueue
from LinkedListQueue import LinkedListQueue
from time import time
from random import randint
def test_enqueue(queue, op_count):
start_time = time()
for i in range(op_count):
queue.enqueue(randint(1, 2000))
return time() - start_time
def test_dequeue(queue, op_count):
start_time = time()
for i in range(op_count):
queue.dequeue()
return time() - start_time
op_count = 10000
array_queue = ArrayQueue()
loop_queue = LoopQueue()
link_queue = LinkedListQueue()
print('ArrayQueue enqueue: ', test_enqueue(array_queue, op_count))
print('LoopQueue enqueue: ', test_enqueue(loop_queue, op_count))
print('LinkQueue enqueue: ', test_enqueue(link_queue, op_count))
print('ArrayQueue dequeue: ', test_dequeue(array_queue, op_count))
print('LoopQueue dequeue: ', test_dequeue(loop_queue, op_count))
print('LinkQueue dequeue: ', test_dequeue(link_queue, op_count))