Created
June 21, 2023 22:18
-
-
Save eduardogpg/00da17bdd1d516c2db9cdec3bfae8a0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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