Python memory profiler

From wikinotes
Revision as of 05:18, 28 August 2020 by Will (talk | contribs) (Created page with "Profile your python script by running it on commandline.<br> Set target function with <code>@profile</code> and execute with <code>python -m memory_profiler file.py</code>. =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Profile your python script by running it on commandline.
Set target function with @profile and execute with python -m memory_profiler file.py.

Documentation

github https://github.com/pythonprofilers/memory_profiler

Install

sudo pip install memory_profiler

Usage

@profile
def foo():
    a = 1
    b = 2
python -m memory_profiler example.py