Skip to content

IPython line magic for showing profiling graphs using gprof2dot and graphviz.

License

Notifications You must be signed in to change notification settings

stefco/profilegraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

profilegraph

pypi badge

A line/cell magic for displaying cProfile results in graph form. Like %time or %%time, but with far more information (with the performance penalty you'd expect from cProfile.run).

Inspired by mattijn/gprof2dot_magic.

A trivial profilegraph example.

Install

This package requires Jupyter with a python kernel to be installed. The only other python dependency is gprof2dot, which is used to convert cProfile output to a graphviz-compatible dotfile and is installed by pip automatically, and a graphviz binary, which is used to render the SVG output. You can install graphviz from the provided download link or using the package manager of your choice.

pip install profilegraph

Use

Load the extension in a Jupyter notebook:

%load_ext profilegraph

Profile a line of code by sticking %profilegraph at the start:

import re
%profilegraph re.sub("biz", "baz", "foobarbiz")

Profile result on re.sub

If you have a whole cell that needs to be profiled, you can use the cell magic form:

%%profilegraph
for i in range(10):
    print(i)

Develop

profilegraph uses flit. Install flit with pip install flit.

Install in editable mode with:

flit install [--symlink] [--python path/to/python]

Upload to PyPI with:

flit publish

About

IPython line magic for showing profiling graphs using gprof2dot and graphviz.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages