profilehooks
============
.. image:: https://github.com/mgedmin/profilehooks/workflows/build/badge.svg?branch=master
:target: https://github.com/mgedmin/profilehooks/actions
.. image:: https://ci.appveyor.com/api/projects/status/github/mgedmin/profilehooks?branch=master&svg=true
:target: https://ci.appveyor.com/project/mgedmin/profilehooks
.. image:: https://coveralls.io/repos/mgedmin/profilehooks/badge.svg?branch=master
:target: https://coveralls.io/r/mgedmin/profilehooks
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.
Changelog
=========
1.13.0 (2024-10-09)
-------------------
- Add support for Python 3.9, 3.10, 3.11, 3.12, and 3.13.
- Drop support for Python 2.7, 3.5 and 3.6.
- Drop support for ``hotshot`` (which was only available for Python 2.7).
1.12.0 (2020-08-20)
-------------------
- Added the ability to pass a text-mode file object to the ``stdout`` kwarg
of the ``@profile()`` decorator and ``FuncProfiler()`` constructor for
capturing output: https://github.com/mgedmin/profilehooks/pull/26.
1.11.2 (2020-03-03)
-------------------
- Fix breakage with ``@functools.lru_cache()``:
https://github.com/mgedmin/profilehooks/issues/25.
- Use ``@functools.wraps()`` so decorated functions now correctly set the
``__wrapped__`` attribute.
1.11.1 (2020-01-30)
-------------------
- Add support for Python 3.8.
- Detect Python source file encoding correctly in ``@coverage``.
https://github.com/mgedmin/profilehooks/issues/24.
1.11.0 (2019-04-23)
-------------------
- New options: ``@timecall(log_name='logger', log_level=DEBUG)``.
https://github.com/mgedmin/profilehooks/pull/20.
- Add Python 3.7 support.
- Drop Python 3.3 and 3.4 support.
1.10.0 (2017-12-09)
-------------------
- ``@timecall()`` now defaults to the highest-precision timer
(``timeit.default_timer()``) instead of ``time.time()``:
https://github.com/mgedmin/profilehooks/pull/11
1.9.0 (2017-01-02)
------------------
- Drop claim of Python 3.2 compatibility. Everything still works, except I'm
no longer running automated tests on 3.2, so things might regress.
- Drop Python 2.6 compatibility.
- Add Python 3.6 compatibility.
1.8.1 (2015-11-21)
------------------
- Include PID in temporary filenames:
https://github.com/mgedmin/profilehooks/issues/6.
- Claim Python 3.5 compatibility.
1.8.0 (2015-03-25)
------------------
- New option: ``@profile(stdout=False)`` to suppress output to sys.stdout.
1.7.1 (2014-12-02)
------------------
- Make ``@profile(profiler='hotshot')`` work again. This was probably broken
in 1.0 or 1.1, but nobody complained.
- Fix missing space in the output of ``@profile(skip=N)``.
- Make ``@coverage_with_hotshot`` output match ``@coverage`` output precisely.
- 100% test coverage.
- Claim Python 3.4 and PyPy compatibility.
1.7 (2013-10-16)
----------------
- Explicitly claim Python 3.3 compatibility.
- Fix Python 3.x bug with @coverage (stop using sys.maxint):
https://github.com/mgedmin/profilehooks/issues/2.
1.6 (2012-06-05)
----------------
- Added Python 3.2 compatibility, dropped Python 2.3, 2.4 and 2.5 compatibility.
- Migrated the source repository to https://github.com/mgedmin/profilehooks
- Added a changelog.
1.5 (2010-08-13)
----------------
- New argument to @timecall: timer (defaults to time.time).
Example: @timecall(timer=time.clock)
- Better documentation.
1.4 (2009-03-31)
----------------
- Added support for cProfile, make it the default profiler when available.
Previously profilehooks supported profile and hotshot only.
1.3 (2008-06-10)
----------------
- Store profile results (when you pass filename to @profile) in pstats format
instead of pickles. Contributed by Florian Schulze.
1.2 (2008-03-07)
----------------
- New argument to: @timecall: immediate (defaults to False).
- Added a test suite.
1.1 (2007-11-07)
----------------
- First release to PyPI, with a setup.py and everything.
- New arguments to @profile: dirs, sort, entries. Contributed by Hanno
Schlichting.
- Preserve function attributes such as __doc__ and __module__ when decorating
them.
- Pydoc-friendly docstring wrapping and other docstring improvements.
1.0 (2006-12-06)
----------------
- Changed licence from GPL to MIT.
- New decorator: @timecall
- New arguments to @profile: skip, filename, immediate.
- Added support for profile, after becoming convinced hotshot was unreliable.
Made it the default profiler.
0.1 (2004-12-30)
----------------
- First public release (it didn't actually have a version number), announced on
my blog: https://mg.pov.lt/blog/profiling.html
- @profile and @coverage decorators that didn't accept any arguments.
- hotshot was the only profiler supported for @profile, while @coverage used
trace.py
Raw data
{
"_id": null,
"home_page": "https://mg.pov.lt/profilehooks/",
"name": "profilehooks",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "profile coverage decorators",
"author": "Marius Gedminas",
"author_email": "marius@gedmin.as",
"download_url": "https://files.pythonhosted.org/packages/18/5a/c69fdf542b730c74b9de1cc2cc02692cd5d6a34a9d95e29217262937f91e/profilehooks-1.13.0.tar.gz",
"platform": null,
"description": "profilehooks\n============\n\n.. image:: https://github.com/mgedmin/profilehooks/workflows/build/badge.svg?branch=master\n :target: https://github.com/mgedmin/profilehooks/actions\n\n.. image:: https://ci.appveyor.com/api/projects/status/github/mgedmin/profilehooks?branch=master&svg=true\n :target: https://ci.appveyor.com/project/mgedmin/profilehooks\n\n.. image:: https://coveralls.io/repos/mgedmin/profilehooks/badge.svg?branch=master\n :target: https://coveralls.io/r/mgedmin/profilehooks\n\n\nIt's a collection of decorators for profiling functions. E.g. to profile a\nsingle function::\n\n from profilehooks import profile\n\n @profile\n def my_function(args, etc):\n pass\n\nThe results will be printed when the program exits (or you can use\n``@profile(immediate=True)``).\n\nIf you're interested in coarse timings and don't want to pay for the overhead\nof profiling, use ::\n\n from profilehooks import timecall\n\n @timecall # or @timecall(immediate=True)\n def my_function(args, etc):\n pass\n\nFinally, you may be interested in seeing line coverage for a single function ::\n\n from profilehooks import coverage\n\n @coverage\n def my_function(args, etc):\n pass\n\nAlso functions can be available in Python console or module if run it with -m arg ::\n\n $ python -m profilehooks\n >>> profile\n <function profile at 0x1005c6488>\n\n $ python -m profilehooks yourmodule\n\nFull documentation is available through ``pydoc profilehooks`` after\ninstallation.\n\nThe home page for this module is https://mg.pov.lt/profilehooks. It has\nscreensho, uh, that is, more examples.\n\n\nChangelog\n=========\n\n1.13.0 (2024-10-09)\n-------------------\n\n- Add support for Python 3.9, 3.10, 3.11, 3.12, and 3.13.\n\n- Drop support for Python 2.7, 3.5 and 3.6.\n\n- Drop support for ``hotshot`` (which was only available for Python 2.7).\n\n\n1.12.0 (2020-08-20)\n-------------------\n\n- Added the ability to pass a text-mode file object to the ``stdout`` kwarg\n of the ``@profile()`` decorator and ``FuncProfiler()`` constructor for\n capturing output: https://github.com/mgedmin/profilehooks/pull/26.\n\n\n1.11.2 (2020-03-03)\n-------------------\n\n- Fix breakage with ``@functools.lru_cache()``:\n https://github.com/mgedmin/profilehooks/issues/25.\n\n- Use ``@functools.wraps()`` so decorated functions now correctly set the\n ``__wrapped__`` attribute.\n\n\n1.11.1 (2020-01-30)\n-------------------\n\n- Add support for Python 3.8.\n\n- Detect Python source file encoding correctly in ``@coverage``.\n https://github.com/mgedmin/profilehooks/issues/24.\n\n\n1.11.0 (2019-04-23)\n-------------------\n\n- New options: ``@timecall(log_name='logger', log_level=DEBUG)``.\n https://github.com/mgedmin/profilehooks/pull/20.\n\n- Add Python 3.7 support.\n\n- Drop Python 3.3 and 3.4 support.\n\n\n1.10.0 (2017-12-09)\n-------------------\n\n- ``@timecall()`` now defaults to the highest-precision timer\n (``timeit.default_timer()``) instead of ``time.time()``:\n https://github.com/mgedmin/profilehooks/pull/11\n\n\n1.9.0 (2017-01-02)\n------------------\n\n- Drop claim of Python 3.2 compatibility. Everything still works, except I'm\n no longer running automated tests on 3.2, so things might regress.\n\n- Drop Python 2.6 compatibility.\n\n- Add Python 3.6 compatibility.\n\n\n1.8.1 (2015-11-21)\n------------------\n\n- Include PID in temporary filenames:\n https://github.com/mgedmin/profilehooks/issues/6.\n\n- Claim Python 3.5 compatibility.\n\n\n1.8.0 (2015-03-25)\n------------------\n\n- New option: ``@profile(stdout=False)`` to suppress output to sys.stdout.\n\n\n1.7.1 (2014-12-02)\n------------------\n\n- Make ``@profile(profiler='hotshot')`` work again. This was probably broken\n in 1.0 or 1.1, but nobody complained.\n\n- Fix missing space in the output of ``@profile(skip=N)``.\n\n- Make ``@coverage_with_hotshot`` output match ``@coverage`` output precisely.\n\n- 100% test coverage.\n\n- Claim Python 3.4 and PyPy compatibility.\n\n\n1.7 (2013-10-16)\n----------------\n\n- Explicitly claim Python 3.3 compatibility.\n\n- Fix Python 3.x bug with @coverage (stop using sys.maxint):\n https://github.com/mgedmin/profilehooks/issues/2.\n\n\n1.6 (2012-06-05)\n----------------\n\n- Added Python 3.2 compatibility, dropped Python 2.3, 2.4 and 2.5 compatibility.\n\n- Migrated the source repository to https://github.com/mgedmin/profilehooks\n\n- Added a changelog.\n\n\n1.5 (2010-08-13)\n----------------\n\n- New argument to @timecall: timer (defaults to time.time).\n Example: @timecall(timer=time.clock)\n\n- Better documentation.\n\n\n1.4 (2009-03-31)\n----------------\n\n- Added support for cProfile, make it the default profiler when available.\n Previously profilehooks supported profile and hotshot only.\n\n\n1.3 (2008-06-10)\n----------------\n\n- Store profile results (when you pass filename to @profile) in pstats format\n instead of pickles. Contributed by Florian Schulze.\n\n\n1.2 (2008-03-07)\n----------------\n\n- New argument to: @timecall: immediate (defaults to False).\n\n- Added a test suite.\n\n\n1.1 (2007-11-07)\n----------------\n\n- First release to PyPI, with a setup.py and everything.\n\n- New arguments to @profile: dirs, sort, entries. Contributed by Hanno\n Schlichting.\n\n- Preserve function attributes such as __doc__ and __module__ when decorating\n them.\n\n- Pydoc-friendly docstring wrapping and other docstring improvements.\n\n\n1.0 (2006-12-06)\n----------------\n\n- Changed licence from GPL to MIT.\n\n- New decorator: @timecall\n\n- New arguments to @profile: skip, filename, immediate.\n\n- Added support for profile, after becoming convinced hotshot was unreliable.\n Made it the default profiler.\n\n\n0.1 (2004-12-30)\n----------------\n\n- First public release (it didn't actually have a version number), announced on\n my blog: https://mg.pov.lt/blog/profiling.html\n\n- @profile and @coverage decorators that didn't accept any arguments.\n\n- hotshot was the only profiler supported for @profile, while @coverage used\n trace.py\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Decorators for profiling/timing/tracing individual functions",
"version": "1.13.0",
"project_urls": {
"Homepage": "https://mg.pov.lt/profilehooks/"
},
"split_keywords": [
"profile",
"coverage",
"decorators"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bc281c526d6cdbeb56aec99c5ec3920ffd7c5b002dbbafb387ebfb33678a1b95",
"md5": "1b36d940c16a2ee1320c66a79ca26a42",
"sha256": "869f63862b3d85e8af44ad7eb01a00203cc7a27a376ed3a51e409399062659c6"
},
"downloads": -1,
"filename": "profilehooks-1.13.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b36d940c16a2ee1320c66a79ca26a42",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10801,
"upload_time": "2024-10-09T13:20:21",
"upload_time_iso_8601": "2024-10-09T13:20:21.445462Z",
"url": "https://files.pythonhosted.org/packages/bc/28/1c526d6cdbeb56aec99c5ec3920ffd7c5b002dbbafb387ebfb33678a1b95/profilehooks-1.13.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "185ac69fdf542b730c74b9de1cc2cc02692cd5d6a34a9d95e29217262937f91e",
"md5": "53c7bf53e59fe6bab4cd21bbd072aba9",
"sha256": "54a541cad49ddccee97b61a617404d7d736bf0bf79d36fbe2ac7caa3a1d9daaf"
},
"downloads": -1,
"filename": "profilehooks-1.13.0.tar.gz",
"has_sig": false,
"md5_digest": "53c7bf53e59fe6bab4cd21bbd072aba9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 17695,
"upload_time": "2024-10-09T13:20:22",
"upload_time_iso_8601": "2024-10-09T13:20:22.778944Z",
"url": "https://files.pythonhosted.org/packages/18/5a/c69fdf542b730c74b9de1cc2cc02692cd5d6a34a9d95e29217262937f91e/profilehooks-1.13.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-09 13:20:22",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "profilehooks"
}