Skip to content

Instantly share code, notes, and snippets.

@elyezer
Created January 5, 2016 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elyezer/62f8c586fb5626f0c171 to your computer and use it in GitHub Desktop.
Save elyezer/62f8c586fb5626f0c171 to your computer and use it in GitHub Desktop.
Using Python memory_profiler
$ pip install memory_profiler psutil
$ python -m memory_profiler sample_file.py
@profile
def func_to_test():
# operations
func()
$ python -m memory_profiler manifest.py
Filename: manifest.py
Line # Mem usage Increment Line Contents
================================================
6 41.332 MiB 0.000 MiB @profile
7 def func():
8 42.215 MiB 0.883 MiB with manifests.clone() as manifest:
9 41.332 MiB -0.883 MiB pass
10 41.332 MiB 0.000 MiB print(manifest.filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment