Skip to content

Commit

Permalink
add info about repeated invocation and interactive use
Browse files Browse the repository at this point in the history
  • Loading branch information
elpres committed Oct 15, 2015
1 parent cd7f8d5 commit 157efab
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ accurately.
implementation and portability notes below for details.


Basic usage
-----------
Usage
-----

It's easy to get started with ``statprof``: ::

Expand All @@ -41,6 +41,38 @@ Or with a contextmanager : ::
with statprof.profile():
my_questionable_function()

The profiler can be invoked at more than one place inside your code and will
report its findings for all of them at once at the end: ::

import statprof

statprof.start()
try:
my_questionable_function()
finally:
statprof.stop()

uninteresting_code()

statprof.start()
try:
my_other_questionable_function()
finally:
statprof.stop()

statprof.display()

However, when you are profiling your code by repeatedly executing it in
IPython, each run will add new samples to the previously collected ones, and
display results aggregated over all runs. Since you will likely just want to
see the results for the last run, remember to reset the profiler first: ::

import statprof

statprof.reset()
with statprof.profile():
my_questionable_function()

For more comprehensive help, run ``pydoc statprof``.


Expand Down

0 comments on commit 157efab

Please sign in to comment.