Help visualize profiling data from cProfile with kcachegrind
Project description
Overview
========
Script to help visualize profiling data collected with the cProfile
python module with the kcachegrind_ (screenshots_) graphical calltree
analyser.
This is a rebranding of the venerable
http://www.gnome.org/~johan/lsprofcalltree.py script by David Allouche
et Al. It aims at making it easier to distribute (e.g. through pypi)
and behave more like the scripts of the debian kcachegrind-converters_
package. The final goal is to make it part of the official upstream
kdesdk_ package.
.. _kcachegrind: http://kcachegrind.sourceforge.net
.. _kcachegrind-converters:
http://packages.debian.org/en/stable/kcachegrind-converters
.. _kdesdk: http://websvn.kde.org/trunk/KDE/kdesdk/kcachegrind/converters/
.. _screenshots: http://images.google.fr/images?q=kcachegrind
Authors
=======
- David Allouche (original author)
- Jp Calderone
- Itamar Shtull-Trauring
- Johan Dahlin
- Olivier Grisel (repackaging and pstats support)
Command line usage
==================
Upon installation you shoould have a `pyprof2calltree` script in your path::
$ pyprof2calltree --help
Usage: /usr/bin/pyprof2calltree [-k] [-o output_file_path] [-i
input_file_path] [-r scriptfile [args]]
Options:
-h, --help show this help message and exit
-o OUTFILE, --outfile=OUTFILE
Save calltree stats to <outfile>
-i INFILE, --infile=INFILE
Read python stats from <infile>
-r SCRIPT, --run-script=SCRIPT
Name of the python script to run to collect profiling
data
-k, --kcachegrind Run the kcachegrind tool on the converted data
Python shell usage
==================
`pyprof2calltree` is also best used from an interactive python shell such as
the defaulft shell. For instance let us profile XML parsing::
>>> from xml.etree import ElementTree
>>> from cProfile import Profile
>>> xml_content = '<a>\n' + '\t<b/><c><d>text</d></c>\n' * 100 + '</a>'
>>> profiler = Profile()
>>> profiler.runctx(
... "ElementTree.fromstring(xml_content)",
... locals(), globals())
>>> from pyprof2calltree import convert, visualize
>>> visualize(profiler.getstats()) # run kcachegrind
>>> convert(profiler.getstats(), 'profiling_results.kgrind') # save for later
or with the ipython_::
In [1]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON
>>> from xml.etree import ElementTree
>>> xml_content = '<a>\n' + '\t<b/><c><d>text</d></c>\n' * 100 + '</a>'
>>> %prun -D out.stats ElementTree.fromstring(xml_content)
*** Profile stats marshalled to file 'out.stats'
>>> from pyprof2calltree import convert, visualize
>>> visualize('out.stats')
>>> convert('out.stats', 'out.kgrind')
>>> results = %prun -r ElementTree.fromstring(xml_content)
>>> visualize(results)
.. _ipython: http://ipython.scipy.org
Change log
==========
- 1.0.2 - 2008-10-16: fix typos in 1.0 release
- 1.0 - 2008-10-16: initial release under the pyprof2calltree name
========
Script to help visualize profiling data collected with the cProfile
python module with the kcachegrind_ (screenshots_) graphical calltree
analyser.
This is a rebranding of the venerable
http://www.gnome.org/~johan/lsprofcalltree.py script by David Allouche
et Al. It aims at making it easier to distribute (e.g. through pypi)
and behave more like the scripts of the debian kcachegrind-converters_
package. The final goal is to make it part of the official upstream
kdesdk_ package.
.. _kcachegrind: http://kcachegrind.sourceforge.net
.. _kcachegrind-converters:
http://packages.debian.org/en/stable/kcachegrind-converters
.. _kdesdk: http://websvn.kde.org/trunk/KDE/kdesdk/kcachegrind/converters/
.. _screenshots: http://images.google.fr/images?q=kcachegrind
Authors
=======
- David Allouche (original author)
- Jp Calderone
- Itamar Shtull-Trauring
- Johan Dahlin
- Olivier Grisel (repackaging and pstats support)
Command line usage
==================
Upon installation you shoould have a `pyprof2calltree` script in your path::
$ pyprof2calltree --help
Usage: /usr/bin/pyprof2calltree [-k] [-o output_file_path] [-i
input_file_path] [-r scriptfile [args]]
Options:
-h, --help show this help message and exit
-o OUTFILE, --outfile=OUTFILE
Save calltree stats to <outfile>
-i INFILE, --infile=INFILE
Read python stats from <infile>
-r SCRIPT, --run-script=SCRIPT
Name of the python script to run to collect profiling
data
-k, --kcachegrind Run the kcachegrind tool on the converted data
Python shell usage
==================
`pyprof2calltree` is also best used from an interactive python shell such as
the defaulft shell. For instance let us profile XML parsing::
>>> from xml.etree import ElementTree
>>> from cProfile import Profile
>>> xml_content = '<a>\n' + '\t<b/><c><d>text</d></c>\n' * 100 + '</a>'
>>> profiler = Profile()
>>> profiler.runctx(
... "ElementTree.fromstring(xml_content)",
... locals(), globals())
>>> from pyprof2calltree import convert, visualize
>>> visualize(profiler.getstats()) # run kcachegrind
>>> convert(profiler.getstats(), 'profiling_results.kgrind') # save for later
or with the ipython_::
In [1]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON
>>> from xml.etree import ElementTree
>>> xml_content = '<a>\n' + '\t<b/><c><d>text</d></c>\n' * 100 + '</a>'
>>> %prun -D out.stats ElementTree.fromstring(xml_content)
*** Profile stats marshalled to file 'out.stats'
>>> from pyprof2calltree import convert, visualize
>>> visualize('out.stats')
>>> convert('out.stats', 'out.kgrind')
>>> results = %prun -r ElementTree.fromstring(xml_content)
>>> visualize(results)
.. _ipython: http://ipython.scipy.org
Change log
==========
- 1.0.2 - 2008-10-16: fix typos in 1.0 release
- 1.0 - 2008-10-16: initial release under the pyprof2calltree name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyprof2calltree-1.0.2.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file pyprof2calltree-1.0.2.tar.gz
.
File metadata
- Download URL: pyprof2calltree-1.0.2.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96406c6f589b14b9b75a947df4ee3f048d2939af2edab8ba00854cb976932023 |
|
MD5 | 31a880e3214145bd5f03a9b3e0516e77 |
|
BLAKE2b-256 | 6f4e3f25c7bfe245c889a4eea384d69560dd7dc80c8304efe5e87fb8d916f981 |
File details
Details for the file pyprof2calltree-1.0.2-py2.5.egg
.
File metadata
- Download URL: pyprof2calltree-1.0.2-py2.5.egg
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff26b7ee80e8d982d34cede74319d7543f75da9e8d584f52ba656ee2b0ce6021 |
|
MD5 | d9a5a61b3c8a08804f1013db2853051a |
|
BLAKE2b-256 | 4f061130c551cefd5d4f79d9a0287b945c56548f47041edb8aec6d9ba8db12d9 |