Wednesday, November 9, 2022

Line profiler for Python

 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.py

3. Run

python -m line_profiler script_to_profile.py.lprof