gprof2dot_magic

magic function that profile any statement as a dot graph using cProfile, gprof2dot and graphviz


Licenses
GPL-3.0/GPL-3.0+
Install
pip install gprof2dot_magic==0.4

Documentation

gprof2dot_magic

Magic function for gprof2dot to profile any Python statement as a DOT graph in JupyterLab or Jupyter Notebook.

installation

Make sure you've the Python package gprof2dot_magic.

pip install gprof2dot_magic

This will also install its dependencies gprof2dot and graphviz.

It is also important to have the Graphviz software installed.

Apperently you can use conda as such (I don't have conda):

conda install python-graphviz

Without conda

For macOS:

brew install graphviz

For Windows (source):

Note: close your "cmd" in which jupyter lab/notebook is running. Existing running CMD dont catch the new changes in Environment variables

usage

To enable the magic function, first load the gprof2dot_magic module

%load_ext gprof2dot_magic

and then profile any line statement as a DOT graph as such:

%gprof2dot print('hello world')