Advertisement
Fhernd

traza-memoria.py

Feb 20th, 2018
1,171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import tracemalloc
  2.  
  3. # Inicio de la traza de memoria:
  4. tracemalloc.start()
  5.  
  6. def factorial(numero):
  7.     """
  8.     Calcula el factorial de un número de forma recursiva.
  9.     """
  10.     if numero == 1:
  11.         return 1
  12.     else:
  13.         return numero * factorial(numero - 1)
  14.        
  15. print(factorial(19))
  16.  
  17. snapshot = tracemalloc.take_snapshot()
  18. estadisticas = snapshot.statistics('lineno')
  19.  
  20. for estadistica in estadisticas:
  21.     print(estadistica)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement