Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
statprof.py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simão Afonso @ Powertools Tech
statprof.py
Commits
52d04eac
Commit
52d04eac
authored
13 years ago
by
Bryan O'Sullivan
Browse files
Options
Downloads
Plain Diff
Merge
parents
a6712ea3
ae06aa00
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.rst
+19
-21
19 additions, 21 deletions
README.rst
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
20 additions
and
22 deletions
README.
tx
t
→
README.
rs
t
+
19
−
21
View file @
52d04eac
...
...
@@ -3,26 +3,27 @@ statprof - statistical profiling for Python
This package provides a simple statistical profiler for Python.
Python's default profiler has been `lsprof` for several years. This is
Python's default profiler has been
`
`lsprof`
`
for several years. This is
an *instrumenting* profiler, which means that it saves data on every
action of interest. In the case of lsprof, it runs at function entry
and exit. This has problems: it can be expensive due to frequent
sampling, and it is blind to hot spots *within* a function.
In contrast, `statprof` samples the call stack periodically (by
In contrast,
`
`statprof`
`
samples the call stack periodically (by
default, 1000 times per second), and it correctly tracks line numbers
*inside* a function. This means that if you have a 50-line function
that contains two hot loops, `statprof` is likely to report them both
accurately.
<b>Note</b>: This package does not yet work on Windows! See the
.. note::
This package does not yet work on Windows! See the
implementation and portability notes below for details.
Basic usage
-----------
It's easy to get started with `statprof`:
It's easy to get started with
`
`statprof`
`: :
:
import statprof
...
...
@@ -33,13 +34,13 @@ It's easy to get started with `statprof`:
statprof.stop()
statprof.display()
For more comprehensive help, run `pydoc statprof`.
For more comprehensive help, run
`
`pydoc statprof`
`
.
Portability
-----------
Because
`
statprof
`
uses the Unix `itimer` signal facility, it does not
Because
*
statprof
*
uses the Unix
`
`itimer`
`
signal facility, it does not
currently work on Windows. (Patches to improve portability would be
most welcome.)
...
...
@@ -47,9 +48,9 @@ most welcome.)
Implementation notes
--------------------
The `statprof` profiler works by setting the Unix profiling signal
`ITIMER_PROF` to go off after the interval you define in the call to
`reset()`. When the signal fires, a sampling routine is run which
The
`
`statprof`
`
profiler works by setting the Unix profiling signal
`
`ITIMER_PROF`
`
to go off after the interval you define in the call to
`
`reset()`
`
. When the signal fires, a sampling routine is run which
looks at the current procedure that's executing, and then crawls up
the stack, and for each frame encountered, increments that frame's
code object's sample count. Note that if a procedure is encountered
...
...
@@ -57,9 +58,9 @@ multiple times on a given stack, it is only counted once. After the
sampling is complete, the profiler resets profiling timer to fire
again after the appropriate interval.
Meanwhile, the profiler keeps track, via `os.times()`, how much CPU
time (system and user -- which is also what `ITIMER_PROF` tracks), has
elapsed while code has been executing within a `start()`/`stop()`
Meanwhile, the profiler keeps track, via
`
`os.times()`
`
, how much CPU
time (system and user -- which is also what
`
`ITIMER_PROF`
`
tracks), has
elapsed while code has been executing within a
`
`start()`
`
/`
`
stop()`
`
block.
The profiler also tries (as much as possible) to avoid counting or
...
...
@@ -70,22 +71,19 @@ History
-------
This package was originally
[
written and released by Andy Wingo
](
http://wingolog.org/archives/2005/10/28/profiling
)
.
written and released by
`
Andy Wingo
<
http://wingolog.org/archives/2005/10/28/profiling
>`_
.
It was ported to modern Python by Alex Frazer, and posted to github by
Jeff Muizelaar. The current maintainer is Bryan O'Sullivan
<bos@serpentine.com>.
Jeff Muizelaar. The current maintainer is `Bryan O'Sullivan <bos@serpentine.com>`_.
Reporting bugs, contributing patches
------------------------------------
The current maintainer of this package is Bryan O'Sullivan
<bos@serpentine.com>.
The current maintainer of this package is `Bryan O'Sullivan <bos@serpentine.com>`_.
Please report bugs using the
[github issue tracker](https://github.com/bos/statprof.py/issues).
Please report bugs using the `github issue tracker <https://github.com/bos/statprof.py/issues>`_.
If you'd like to contribute patches, please do - the source is on
github, so please just issue a pull request.
github, so please just issue a pull request.
::
$ git clone git://github.com/bos/statprof.py
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
52d04eac
...
...
@@ -20,7 +20,7 @@ setup(
keywords
=
"
profiling
"
,
url
=
"
http://packages.python.org/statprof
"
,
py_modules
=
[
'
statprof
'
],
long_description
=
read
(
'
README.
tx
t
'
),
long_description
=
read
(
'
README.
rs
t
'
),
classifiers
=
[
"
Development Status :: 3 - Alpha
"
,
"
Topic :: Utilities
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment