python profiling

This blog show simple steps that can profile a python code and then visualize the profile info.

  1. Run the python code with cProfile
1
python3 -m cProfile -o test.profile __main__.py
  1. Install snakeviz profile visualization tool
1
pip3 install snakeviz
  1. Run the following command. The tool will host a local webpage that we can access.
1
snakeviz test.profile

That’s it.

Built with Hugo
Theme Stack designed by Jimmy