executiontime
This module provides a simple function decorator to display its execution time on the console or in the logs.
Installation
Simply install the package with pip:
pip install executiontime
Usage
You simply need to decorate the function and specify a message template. If you do not provide a message, one will be created for you based on the names of the decorated function and its module.
from executiontime import printexecutiontime
@printexecutiontime("My function's execution took {0}")
def my_function():
pass
if __name__ == '__main__':
my_function()
By default, the message will be displayed on the console. But it is also possible to specify a log function, for example.
from logging import info, INFO, basicConfig
from executiontime import printexecutiontime
@printexecutiontime("My function's execution took {0}", display=info)
def my_function():
pass
if __name__ == '__main__':
basicConfig(level=INFO)
my_function()
It is also easy to add a little bit of color:
from executiontime import printexecutiontime, LIGHTBLUE
@printexecutiontime("My function's execution took {0}", color=LIGHTBLUE)
def my_function():
pass
if __name__ == '__main__':
my_function()
Changelog
- v0.4.4
- No need of a time zone to calculate an elapsed time.
- v0.4.3
- Improve
publish.shscript to get current PyPI version.
- Improve
- v0.4.2
- Update dependencies
- v0.4.1
- The message is now optional and a default one is provided, based on the names of the decorated function and its module.
- v0.4.0
- Refresh the dependencies
- Replace deprecated datetime.utcnow()
Release files for executiontime 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| executiontime-0.4.6.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| executiontime-0.4.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / executiontime-0.4.6.tar.gz
| Download URL | executiontime-0.4.6.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3423217b74891eb8aa2cd18292c1ad92c489407c837e1b9a7bda4623ecf64e60
|
|
BLAKE2b-256 checksum How to use checksums |
d4bb9b685f0aa7b3f75554e6f4b03958273cb5c0f8f813649bc790606bcd0db4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
|
Release files / executiontime-0.4.6-py3-none-any.whl
| Download URL | executiontime-0.4.6-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b5cdc19145759814117ea654a821548de450b11058d1649e7783a279af71f2b
|
|
BLAKE2b-256 checksum How to use checksums |
8d70a481abc604ffcc6bc710ac8890826202630e512d8d688c1bd4ba90666d15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
|