https://github.com/pyutils/line_profiler
pip install line_profiler
1. Add @profile decorator to function you want to profile:
@profile
def summarize_file_size(archive_file):
...
2. Run
kernprof -l script_to_profile.py3. Run
python -m line_profiler script_to_profile.py.lprof