~launchpad-pqm/lsprof/trunk

« back to all changes in this revision

Viewing changes to README.html

  • Committer: Francis J. Lacoste
  • Date: 2008-06-19 02:04:04 UTC
  • Revision ID: francis.lacoste@canonical.com-20080619020404-80u777dsc9u39zdj
Import from http://codespeak.net/svn/user/arigo/hack/misc/lsprof/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
4
<head>
 
5
<meta http-equiv="Content-Type" content="text/html; charset=latin1" />
 
6
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
 
7
<title>'cProfile': the lsprof profiler</title>
 
8
</head>
 
9
<body>
 
10
<div class="document" id="cprofile-the-lsprof-profiler">
 
11
<h1 class="title">'cProfile': the lsprof profiler</h1>
 
12
<p>This svn repository directory contains 'cProfile', a C replacement for
 
13
the standard 'profile' module.  It should work with any not-too-old
 
14
version of Python.  It is now included in the standard library of Python
 
15
2.5.</p>
 
16
<p>Therefore, the situation of the profilers in Python is as follows:</p>
 
17
<p>'profile.Profile' is the ages-old pure Python profiler.  At the end of a
 
18
run, it builds a dict that is inspected by 'pstats.Stats'.  It has some
 
19
recent support for profiling C calls, which however make it crash in
 
20
some cases <a class="reference" href="https://sourceforge.net/tracker/?group_id=5470&amp;atid=105470&amp;func=detail&amp;aid=1117670">[1]</a>.  And of course it's slow (makes a run take about 10x
 
21
longer).</p>
 
22
<p>'hotshot', new from 2.2, is quite faster (reportedly, only 30% added
 
23
overhead).  The log file is then loaded and turned into an instance of
 
24
the same 'pstats.Stats'.  This loading takes ages.  The reason is that
 
25
the log file only records events, and loading is done by instantiating a
 
26
'profile.Profile' and sending it all the events.  In other words, it
 
27
takes exactly as long as the time it saved in the first place!
 
28
Moreover, for some reasons, the results given by hotshot seem sometimes
 
29
quite wrong.  (I don't understand why, but I've seen it myself, and it's
 
30
been reported by various people, e.g. <a class="reference" href="http://sourceforge.net/tracker/?group_id=5470&amp;atid=305470&amp;func=detail&amp;aid=1212837">[2]</a>.)  'hotshot' doesn't know
 
31
about C calls, but it can log line events, although this information is
 
32
lost(!) in the final conversion to a 'pstats.Stats'.</p>
 
33
<p>'lsprof' is a third profiler by Brett Rosen and Ted Czotter, posted on
 
34
SF in June 2005 <a class="reference" href="http://sourceforge.net/tracker/?group_id=5470&amp;atid=305470&amp;func=detail&amp;aid=1212837">[2]</a>.  Michael Hudson and I did some minor clean-ups and
 
35
improvements on it, and it seems to be quite useful.  It is, for
 
36
example, the only of the three profilers that managed to give sensible
 
37
information about the PyPy translation process without crashing,
 
38
allowing us to accelerate it from over 30 to under 20 minutes.  The SF
 
39
patch contains a more detailed account on the reasons for writing
 
40
'lsprof'.  The current version <a class="reference" href="http://codespeak.net/svn/user/arigo/hack/misc/lsprof">[3]</a> supports C calls but not line events.
 
41
It has its own simple internal interface, which is wrapped in an
 
42
interface compatible with 'profile' by a module called 'cProfile'.
 
43
However, unlike the other two profilers, it can record detailed stats
 
44
about children, which I found quite useful (e.g. how much time is spent
 
45
in a function when it is called by another specific function).</p>
 
46
<p>'lsprof' has been added to the standard library of Python 2.5.  Its
 
47
public interface is in 'cProfile', which is designed to be a drop-in
 
48
replacement for 'profile'.  The 'pstats' module has also been extended
 
49
in 2.5 to show the extra children statistics recorded by 'cProfile', if
 
50
present.  In the stand-alone version of lsprof/cProfile that you can
 
51
download from <a class="reference" href="http://codespeak.net/svn/user/arigo/hack/misc/lsprof">[3]</a>, the extended pstats module is called 'pstats2' to
 
52
avoid collision with the standard 'pstats'.  The easiest way to read the
 
53
documentation of cProfile is by looking at the Python 2.5 documentation
 
54
<a class="reference" href="http://www.python.org/doc/2.5/lib/module-profile.html">[4]</a>.</p>
 
55
<p>-+- Armin</p>
 
56
</div>
 
57
</body>
 
58
</html>