Created
February 20, 2018 12:13
-
-
Save Fhernd/bc63d67fa1dde02caac436a6f3740091 to your computer and use it in GitHub Desktop.
Traza de uso de memoria en Python.
This file contains 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 tracemalloc | |
# Inicio de la traza de memoria: | |
tracemalloc.start() | |
def factorial(numero): | |
""" | |
Calcula el factorial de un número de forma recursiva. | |
""" | |
if numero == 1: | |
return 1 | |
else: | |
return numero * factorial(numero - 1) | |
print(factorial(19)) | |
snapshot = tracemalloc.take_snapshot() | |
estadisticas = snapshot.statistics('lineno') | |
for estadistica in estadisticas: | |
print(estadistica) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment