mirror of
https://github.com/iritmaximus/tira.git
synced 2026-10-12 19:13:47 +03:00
25 lines
439 B
Python
25 lines
439 B
Python
import collections
|
|
import time
|
|
|
|
def stack(n):
|
|
start = time.time()
|
|
stack = collections.deque()
|
|
for x in range(n):
|
|
stack.append(x)
|
|
|
|
add_end = time.time()
|
|
for x in range(n):
|
|
stack.popleft()
|
|
|
|
end = time.time()
|
|
|
|
return f"Total: {end - start:.2f} seconds, to add: {add_end - start:.2f}, to delete: {end - add_end:.2f}"
|
|
|
|
|
|
|
|
def main():
|
|
print(stack(10**5))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|