Timeit Decorator
Overview
timeit_decorator is a Python package providing a versatile decorator for timing the execution of functions. It supports executing functions multiple times, in parallel, and can use either threading or multiprocessing depending on the nature of the task.
Installation
To install timeit_decorator, run the following command:
pip install timeit_decorator
Usage
Basic Usage
Here's a simple example of how to use the timeit decorator:
from timeit_decorator import timeit
@timeit(runs=5, workers=2)
def sample_function():
# Function implementation
Using Multiprocessing
For CPU-bound tasks, you can enable multiprocessing:
from timeit_decorator import timeit
@timeit(runs=10, workers=4, use_multiprocessing=True)
def cpu_intensive_function():
# CPU-bound function implementation
Using Threading (Default)
For I/O-bound tasks, the default threading is more efficient:
from timeit_decorator import timeit
@timeit(runs=5, workers=2)
def io_bound_function():
# I/O-bound function implementation
Features
- Multiple Runs: Execute the function multiple times for more accurate timing.
- Concurrency: Run tasks in parallel using either threading or multiprocessing.
- Flexible: Suitable for both CPU-bound and I/O-bound tasks.
- Customizable: Control the number of runs and workers, and choose between threading and multiprocessing.
Requirements
timeit_decorator requires Python 3.x.
Contributing
Contributions to timeit_decorator are welcome! Please read our contributing guidelines for more details.
License
timeit_decorator is released under the MIT License.
Metadata
Release files for timeit-decorator 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 | |
|---|---|---|---|
| timeit_decorator-1.0.0.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| timeit_decorator-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / timeit_decorator-1.0.0.tar.gz
| Download URL | timeit_decorator-1.0.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04a43916226d39054f683c9aaf25bef00076f861ac4d4ef8c56578098b5183a9
|
|
BLAKE2b-256 checksum How to use checksums |
3b3b83ad4019d6d36d374bc6a759e85c2ff5d1aaf98058940df03a62e24b52da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / timeit_decorator-1.0.0-py3-none-any.whl
| Download URL | timeit_decorator-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
971fcd79832ce9dfd1599d7ee44842ac1582bf44b5157f6919f8e3f69db32a5c
|
|
BLAKE2b-256 checksum How to use checksums |
b89aca334fd934e7ba652533dec53eda1189d791172ea52bd094d5387b0c2a46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|