Skip to content

Instantly share code, notes, and snippets.

@geoffroy-noel-ddh
Created February 10, 2019 12:39
Show Gist options
  • Save geoffroy-noel-ddh/571fb6489e5ec0b3346ce8573d98c69d to your computer and use it in GitHub Desktop.
Save geoffroy-noel-ddh/571fb6489e5ec0b3346ce8573d98c69d to your computer and use it in GitHub Desktop.
Profiling python
# Setup
# see https://jiffyclub.github.io/snakeviz/
pip install snakeviz
# run your script and generate profiling info
python -m cProfile -o program.prof myscrypt.py myargument
# visualise the results in your browser
snakeviz program.prof
# if used inside a container / VM
# 1. open the port 8080 on the VM
# or create a port forwarding (e.g. Virtualbox)
# 2. start the UI
snakeviz program.prof -s -H 0.0.0.0
# 3. then open http://localhost:8080 or http://MYVMIP:8080 with your browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment