line_profiler

pip install line_profiler
# добавит в кодде декоратор @profile
kernprof -v -l script.py