.\" Man page generated from reStructuredText. . .TH PYPROF2CALLTREE 1 "" "" "General Commands Manual" .SH NAME Pyprof2calltree \- visualize Python cProfile data in kcachegrind . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH DESCRIPTION .sp Script to help visualize profiling data collected with the cProfile Python module with the \fI\%kcachegrind\fP graphical calltree analyser. .sp This is a rebranding of the venerable \fI\%http://www.gnome.org/~johan/lsprofcalltree.py\fP 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 \fI\%kcachegrind\-converters\fP package. The final goal is to make it part of the official upstream \fI\%kdesdk\fP package. .SH OPTIONS .sp Upon installation you should have a \fIpyprof2calltree\fP script in your path: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ pyprof2calltree \-\-help usage: pyprof2calltree [\-h] [\-o output_file_path] [\-i input_file_path] [\-k] [\-r scriptfile [args ...]] optional arguments: \-h, \-\-help show this help message and exit \-o output_file_path, \-\-outfile output_file_path Save calltree stats to \-i input_file_path, \-\-infile input_file_path Read Python stats from \-k, \-\-kcachegrind Run the kcachegrind tool on the converted data \-r scriptfile [args ...], \-\-run\-script scriptfile [args ...] Name of the Python script to run to collect profiling data .ft P .fi .UNINDENT .UNINDENT .SH PYTHON SHELL USAGE .sp \fIpyprof2calltree\fP is also best used from an interactive Python shell such as the default shell. For instance let us profile XML parsing: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C >>> from xml.etree import ElementTree >>> from cProfile import Profile >>> xml_content = \(aq\en\(aq + \(aq\ettext\en\(aq * 100 + \(aq\(aq >>> profiler = Profile() >>> profiler.runctx( \&... "ElementTree.fromstring(xml_content)", \&... locals(), globals()) >>> from pyprof2calltree import convert, visualize >>> visualize(profiler.getstats()) # run kcachegrind >>> convert(profiler.getstats(), \(aqprofiling_results.kgrind\(aq) # save for later .ft P .fi .UNINDENT .UNINDENT .sp or with the \fI\%ipython\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C In [1]: %doctest_mode Exception reporting mode: Plain Doctest mode is: ON >>> from xml.etree import ElementTree >>> xml_content = \(aq\en\(aq + \(aq\ettext\en\(aq * 100 + \(aq\(aq >>> %prun \-D out.stats ElementTree.fromstring(xml_content) *** Profile stats marshalled to file \(aqout.stats\(aq >>> from pyprof2calltree import convert, visualize >>> visualize(\(aqout.stats\(aq) >>> convert(\(aqout.stats\(aq, \(aqout.kgrind\(aq) >>> results = %prun \-r ElementTree.fromstring(xml_content) >>> visualize(results) .ft P .fi .UNINDENT .UNINDENT .\" Generated by docutils manpage writer. .