kernprof

line-by-line profiling for Python

Install

All systems
curl cmd.cat/kernprof.sh
Debian Debian
apt-get install python3-line-profiler
Ubuntu
apt-get install python3-line-profiler
image/svg+xml Kali Linux
apt-get install python3-line-profiler
Fedora
dnf install python2-line_profiler
Windows (WSL2)
sudo apt-get update sudo apt-get install python3-line-profiler

python3-line-profiler

line-by-line profiling for Python

LineProfiler can be given functions to profile, and it will time the execution of each individual line inside those functions. In a typical workflow, one only cares about line timings of a few functions because wading through the results of timing every single line of code would be overwhelming. However, LineProfiler does need to be explicitly told what functions to profile. If you are using IPython, there is an implementation of an %lprun magic command which will let you specify functions to profile and a statement to execute.

python2-line_profiler

Line-by-line profiler for python