To use pyinstrument, make sure that pyinstrument is installed first.
python -m pip install pyinstrument
Once installed, pyinstrument can be run from the command line to show pretty tree-based visualisations on where your python script spends the most time.
If you'd be used to calling a program via:
Then you can have pyinstrument profile that script via;
In case you didn't know, pyinstrument is using rich under the hood to make such pretty interactive visuals. If you're curious to learn how, you may enjoy our tutorial on trees in rich.