Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fee6f33e
Commit
fee6f33e
authored
Mar 23, 2004
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more markup nits
parent
69200fa8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
Doc/lib/libprofile.tex
Doc/lib/libprofile.tex
+13
-12
No files found.
Doc/lib/libprofile.tex
View file @
fee6f33e
...
...
@@ -104,15 +104,15 @@ This section is provided for users that ``don't want to read the
manual.'' It provides a very brief overview, and allows a user to
rapidly perform profiling on an existing application.
To profile an application with a main entry point of
\
samp
{
foo()
}
, you
would add the following to your module:
To profile an application with a main entry point of
\
function
{
foo()
}
,
you
would add the following to your module:
\begin{verbatim}
import profile
profile.run('foo()')
\end{verbatim}
The above action would cause
\
samp
{
foo()
}
to be run, and a series of
The above action would cause
\
function
{
foo()
}
to be run, and a series of
informative lines (the profile) to be printed. The above approach is
most useful when working with the interpreter. If you would like to
save the results of a profile into a file for later examination, you
...
...
@@ -137,8 +137,9 @@ python /usr/local/lib/python1.5/profile.py myscript.py
profile.py [-o output
_
file] [-s sort
_
order]
\end{verbatim}
\samp
{
-s
}
only applies to stdout (i.e.
\samp
{
-o
}
is not supplied.
Look in the
\class
{
Stats
}
documentation for valid sort values.
\programopt
{
-s
}
only applies to standard output (
\programopt
{
-o
}
is
not supplied). Look in the
\class
{
Stats
}
documentation for valid sort
values.
When you wish to review the profile, you should use the methods in the
\module
{
pstats
}
module. Typically you would load the statistics data as
...
...
@@ -151,7 +152,7 @@ p = pstats.Stats('fooprof')
The class
\class
{
Stats
}
(the above code just created an instance of
this class) has a variety of methods for manipulating and printing the
data that was just read into
\
samp
{
p
}
. When you ran
data that was just read into
\
code
{
p
}
. When you ran
\function
{
profile.run()
}
above, what was printed was the result of three
method calls:
...
...
@@ -199,8 +200,8 @@ p.sort_stats('file').print_stats('__init__')
\end{verbatim}
This will sort all the statistics by file name, and then print out
statistics for only the class init methods (
'caus
e they are spelled
with
\
samp
{__
init
__}
in them). As one final example, you could try:
statistics for only the class init methods (
sinc
e they are spelled
with
\
code
{__
init
__}
in them). As one final example, you could try:
\begin{verbatim}
p.sort
_
stats('time', 'cum').print
_
stats(.5, 'init')
...
...
@@ -213,7 +214,7 @@ of its original size, then only lines containing \code{init} are
maintained, and that sub-sub-list is printed.
If you wondered what functions called the above functions, you could
now (
\
samp
{
p
}
is still sorted according to the last criteria) do:
now (
\
code
{
p
}
is still sorted according to the last criteria) do:
\begin{verbatim}
p.print
_
callers(.5, 'init')
...
...
@@ -423,7 +424,7 @@ identifying the basis of a sort (example: \code{'time'} or
When more than one key is provided, then additional keys are used as
secondary criteria when there is equality in all keys selected
before them. For example,
\
samp
{
sort
_
stats('name', 'file')
}
will sort
before them. For example,
\
code
{
sort
_
stats('name', 'file')
}
will sort
all the entries according to their function name, and resolve all ties
(identical function names) by sorting by file name.
...
...
@@ -495,14 +496,14 @@ print_stats(.1, 'foo:')
\end{verbatim}
would first limit the printing to first 10
\%
of list, and then only
print functions that were part of filename
\
samp
{
.*foo:
}
. In
print functions that were part of filename
\
file
{
.*foo:
}
. In
contrast, the command:
\begin{verbatim}
print
_
stats('foo:', .1)
\end{verbatim}
would limit the list to all functions having file names
\
samp
{
.*foo:
}
,
would limit the list to all functions having file names
\
file
{
.*foo:
}
,
and then proceed to only print the first 10
\%
of them.
\end{methoddesc}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment