Use a line_profiler

There’s a neat 3rd party project called line_profiler that is designed to profile the time each individual line takes to execute. It also includes a script called kernprof for profiling Python applications and scripts using line_profiler. Just use pip to install the package.

Getting started with line_profiler

Here’s how:

pip3 install line_profiler

Get hands-on with 1400+ tech skills courses.