File: test_queue.py

package info (click to toggle)
cython 0.29.32-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,028 kB
  • sloc: python: 67,518; ansic: 14,866; cpp: 1,340; xml: 1,031; makefile: 393; lisp: 206; sh: 137; sed: 11
file content (36 lines) | stat: -rw-r--r-- 564 bytes parent folder | download | duplicates (4)
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
from __future__ import print_function

import time

import queue

Q = queue.Queue()

Q.append(10)
Q.append(20)
print(Q.peek())
print(Q.pop())
print(Q.pop())
try:
    print(Q.pop())
except IndexError as e:
    print("Error message:", e)  # Prints "Queue is empty"

i = 10000

values = range(i)

start_time = time.time()

Q.extend(values)

end_time = time.time() - start_time

print("Adding {} items took {:1.3f} msecs.".format(i, 1000 * end_time))

for i in range(41):
    Q.pop()

Q.pop()
print("The answer is:")
print(Q.pop())