Skip to content

Instantly share code, notes, and snippets.

@eduardogpg
Created June 21, 2023 22:18
Show Gist options
  • Save eduardogpg/00da17bdd1d516c2db9cdec3bfae8a0c to your computer and use it in GitHub Desktop.
Save eduardogpg/00da17bdd1d516c2db9cdec3bfae8a0c to your computer and use it in GitHub Desktop.
import time
from stack import Stack
from stackll import StackLL
from collections import deque
total = 100_000_000
start = time.time()
def timer_decorator(function):
def wrapper():
start = time.time()
function()
print(time.time() - start)
return wrapper
@timer_decorator
def test_simple_stack():
print("Stack con List")
stack = Stack(total)
for x in range(0, total):
stack.push(x)
for x in range(0, total):
stack.pop()
@timer_decorator
def test_stack_ll():
print("Stack con List Enlazada")
stack = StackLL()
for x in range(0, total):
stack.push(x)
for x in range(0, total):
stack.pop()
@timer_decorator
def test_deque():
print("Stack con Deque")
stack = deque()
for x in range(0, total):
stack.apppend(x)
for x in range(0, total):
stack.pop()
test_simple_stack()
test_stack_ll()
test_deque()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment