Skip to content
Python decorators for profiling/tracing/timing a single function
Branch: master
Clone or download
mgedmin Replace 'make test-all-pythons' with tox
So I wouldn't have to keep SUPPORTED_PYTHON_VERSIONS up to date.
Latest commit 2b1d3b6 Apr 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.coveragerc Add a .coveragerc Nov 6, 2014
.gitignore Add an appveyor.yml Dec 11, 2015
.travis.yml
CHANGES.rst Update changelog and bump minor version Apr 12, 2019
LICENSE
MANIFEST.in
Makefile Replace 'make test-all-pythons' with tox Apr 12, 2019
README.rst
appveyor.yml
profilehooks.py Update changelog and bump minor version Apr 12, 2019
pytest.ini
release.mk Update release.mk to 1.3 Nov 8, 2018
setup.cfg
setup.py Claim Python 3.7 support Aug 7, 2018
test_profilehooks.py Make it possible to use pytest to run tests Apr 12, 2019
tox.ini

README.rst

profilehooks

https://travis-ci.org/mgedmin/profilehooks.svg?branch=master https://ci.appveyor.com/api/projects/status/github/mgedmin/profilehooks?branch=master&svg=true https://coveralls.io/repos/mgedmin/profilehooks/badge.svg?branch=master

It's a collection of decorators for profiling functions. E.g. to profile a single function:

from profilehooks import profile

@profile
def my_function(args, etc):
    pass

The results will be printed when the program exits (or you can use @profile(immediate=True)).

If you're interested in coarse timings and don't want to pay for the overhead of profiling, use

from profilehooks import timecall

@timecall       # or @timecall(immediate=True)
def my_function(args, etc):
    pass

Finally, you may be interested in seeing line coverage for a single function

from profilehooks import coverage

@coverage
def my_function(args, etc):
    pass

Also functions can be available in Python console or module if run it with -m arg

$ python -m profilehooks
>>> profile
<function profile at 0x1005c6488>

$ python -m profilehooks yourmodule

Full documentation is available through pydoc profilehooks after installation.

The home page for this module is https://mg.pov.lt/profilehooks. It has screensho, uh, that is, more examples.

You can’t perform that action at this time.