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;