A programmatic approach to function runtime estimation.
Project description
functimer
A programmatic approach to function runtime estimation.
About
This package first came about as a way to serve my needs during an Algorithms class in college.
It started as a function that stored time elapsed results in a global dictionary, where the key was a tuple of the functions name and return value.
Now it's just a bit different.
Installation
-
PYPI:
pip install functimer
-
Manual:
poetry install --no-dev poetry build pip install dist/*.whl
How to install Poetry.
Quick Example
Comprehensive Examples in examples/
-
Python
@timed(unit=Unit.SECOND, number=1) def timed_sleep(seconds): sleep(seconds) runtime = timed_sleep(1) "1.00 s"
-
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 Average runtime of 10,000 executions: 0.15 µs sum([1, 2, 3]) -> 6 $ python -m functimer "(lambda x: x+x)(10)" --return 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 Average runtime of 10,000 executions: 0.50 µs functimer.util.get_unit('1.00 s') -> Unit.SECOND $ python -m functimer "functimer.classes.Unit.from_str('s')" --return Average runtime of 10,000 executions: 0.25 µs functimer.classes.Unit.from_str('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.3.1.tar.gz
(9.2 kB
view hashes)
Built Distribution
functimer-1.3.1-py3-none-any.whl
(12.3 kB
view hashes)
Close
Hashes for functimer-1.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fab3fba9beaca56bde9e87f867c4761d0b300892ca5e4cea2b79a6459c7fdc7c |
|
MD5 | d72c384e362c61714342fe76c95ed41e |
|
BLAKE2b-256 | 4dc06f8a78a7b9dc513ceef6c434e50d747c303e7b3ddf65b629839d488a13da |