timefunc ⏱️
Function execution timing utilities for Python.
Installation
pip install timefunc
Usage
Decorator
from timefunc import timeit
@timeit
def slow_function():
time.sleep(1)
slow_function()
# Output: slow_function: 1.0012s
Context Manager
from timefunc import Timer
with Timer("database query") as t:
results = db.query()
print(f"Query took {t.elapsed:.2f}s")
Benchmark
from timefunc import benchmark
@benchmark(runs=100, warmup=5)
def function_to_test():
# code to benchmark
pass
function_to_test()
# Output:
# function_to_test:
# Runs: 100
# Mean: 1.23ms
# Median: 1.20ms
# Min: 1.01ms
# Max: 2.45ms
# Std Dev: 0.15ms
Features
- ⏱️ Function timing decorator
- 📊 Benchmarking with statistics
- 🔄 Context manager support
- 📈 Warmup runs for accurate benchmarks
- 📝 Human-readable output
API
@timeit
@timeit(name="custom", print_result=True)
def func(): pass
@benchmark
@benchmark(runs=10, warmup=1, name="custom")
def func(): pass
Timer
with Timer("name", print_result=False) as t:
pass
print(t.elapsed) # seconds as float
print(t.result) # TimingResult object
License
MIT
Metadata
Release files for pytimefunc-rj 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pytimefunc_rj-1.0.0.tar.gz | 3.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytimefunc_rj-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / pytimefunc_rj-1.0.0.tar.gz
| Download URL | pytimefunc_rj-1.0.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e2afbc03b79c0c1283226a9169a98d8d626d0a96868f99fea297c425f97ce7f
|
|
BLAKE2b-256 checksum How to use checksums |
81b3bdcfdd004562f76e3eb1c9f1611120501b9df56c16fae4087c0355625774
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / pytimefunc_rj-1.0.0-py3-none-any.whl
| Download URL | pytimefunc_rj-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
681793ad1cc25011fabbd6fd46cc3feb6e6e02e66b83ad6928224e19c9ac719b
|
|
BLAKE2b-256 checksum How to use checksums |
b044d1ccf2313235cea405c6b437d1772d9f7b79e79b6ceac110f01c67385c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for pytimefunc-rj 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.