pyprof2calltree 1.1.0
Help visualize profiling data from cProfile with kcachegrind
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.
Authors and contributors
- David Allouche (original author)
- Jp Calderone
- Itamar Shtull-Trauring
- Johan Dahlin
- Olivier Grisel (repackaging and pstats support)
- David Glick (fix in conversion algorithm)
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)
Change log
- 1.1.0 - 2008-12-21: integrate fix in conversion by David Glick
- 1.0.3 - 2008-10-16: fix typos in 1.0 release
- 1.0 - 2008-10-16: initial release under the pyprof2calltree name
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| pyprof2calltree-1.1.0.tar.gz (md5) | Source | 2008-12-21 18:34:34 | 5KB | 1276 | |
| pyprof2calltree-1.1.0-py2.5.egg (md5) | Python Egg | 2.5 | 2008-12-21 18:34:34 | 9KB | 1957 |
- Author: Olivier Grisel <olivier grisel at ensta org>
- Home Page: http://www.bitbucket.org/ogrisel/pyprof2calltree/overview/
- Keywords: profiler visualization programming tool kde kcachegrind
- License: BSD
-
Categories
- Development Status :: 5 - Production/Stable
- Environment :: Console
- Environment :: X11 Applications :: KDE
- License :: OSI Approved :: BSD License
- Operating System :: POSIX
- Operating System :: Unix
- Programming Language :: Python :: 2.5
- Programming Language :: Python :: 2.6
- Programming Language :: Python :: 2.7
- Topic :: Desktop Environment :: K Desktop Environment (KDE)
- Topic :: Software Development
- Topic :: Software Development :: Quality Assurance
- Topic :: System :: System Shells
- Topic :: Utilities
- Package Index Owner: ogrisel
- DOAP record: pyprof2calltree-1.1.0.xml
Log in to rate this package.
