A decorator/wrapper package to time a given function.
Project description
functimer
A decorator/wrapper package to time a given function.
Installation
-
PYPI:
pip install functimer
-
Manual:
poetry build pip install dist/*.whl
How to install Poetry.
Quick Example
Comprehensive Examples in examples
From Python
@timed(unit=Unit.second, number=1)
def timed_sleep(seconds):
sleep(seconds)
runtime = timed_sleep(1)
"1.00 s"
From the command line
$ python -m functimer "sum([1, 2, 3])"
Average runtime of 10,000 executions: 0.15 µs
$ python -m functimer "sum([1, 2, 3])" --return True
Average runtime of 10,000 executions: 0.15 µs
sum([1, 2, 3]) -> 6
$ python -m functimer "(lambda x: x+x)(10)" --return true
Average runtime of 10,000 executions: 0.14 µs
(lambda x: x+x)(10) -> 20
$ python -m functimer "functimer.util.get_unit('1.00 s')" --return true
Average runtime of 10,000 executions: 0.50 µs
functimer.util.get_unit('1.00 s') -> Unit.second
Tests
Run tox
in the root directory of the repo.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
functimer-1.2.0.tar.gz
(8.8 kB
view hashes)
Built Distribution
functimer-1.2.0-py3-none-any.whl
(11.5 kB
view hashes)
Close
Hashes for functimer-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068ef48a256fe4169a73e15cea6afebed04251406036b8e01f0089e67fa5754c |
|
MD5 | 5c2ccdfe43e474bbb09e18456a2b61c0 |
|
BLAKE2b-256 | f10ab55cc5d50115c4c121620586e031be3db225aeace9110991b1c52e9c3c33 |