A simple function decorator to display its execution time on the console or in the logs.
Project description
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.
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()
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
executiontime-0.3.5.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file executiontime-0.3.5.tar.gz
.
File metadata
- Download URL: executiontime-0.3.5.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/5.15.0-92-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a15cde32c061ceab03edced80c3fbff4255cdd8cd12d56bb4a0b2c77788a55f4 |
|
MD5 | f5b6fd7a587c99b59783881d46c4449c |
|
BLAKE2b-256 | 88af8a258eb0598fb5722c66196b74051584c83c52cf44d8c8aeb499d4851289 |
File details
Details for the file executiontime-0.3.5-py3-none-any.whl
.
File metadata
- Download URL: executiontime-0.3.5-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.7 Linux/5.15.0-92-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0c53b325982c7b759c74ac50680a94e1657dc49506a2367f430adc5ffce4b66 |
|
MD5 | 3d258e52ddf01b07fe1be3badd93e777 |
|
BLAKE2b-256 | f7b4e45bfe531e7f82b2150d46cd4013576ceaf04e45e6116bc2ad7c68cc5b52 |