Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created February 20, 2018 12:13
Show Gist options
  • Save Fhernd/bc63d67fa1dde02caac436a6f3740091 to your computer and use it in GitHub Desktop.
Save Fhernd/bc63d67fa1dde02caac436a6f3740091 to your computer and use it in GitHub Desktop.
Traza de uso de memoria en Python.
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