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.6.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file executiontime-0.3.6.tar.gz
.
File metadata
- Download URL: executiontime-0.3.6.tar.gz
- Upload date:
- Size: 3.0 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 | 897906e2be96c1ecb7acafb9b9dab011a8e547597ae7e5b104855efd5bf9ef5b |
|
MD5 | 8ed183601a3bf3f9f7cb7e7945ba98dd |
|
BLAKE2b-256 | 496288ac91a53d02a21c214e2a3b2e849cc8fb026e5fc6175a71eb576d065ae9 |
File details
Details for the file executiontime-0.3.6-py3-none-any.whl
.
File metadata
- Download URL: executiontime-0.3.6-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 | 482e533fcdbe4ba0486ddd527bb2b29652b927a3067e4ced828a75a200912dab |
|
MD5 | 0fbc7141312d28f145255ce13b99e8e7 |
|
BLAKE2b-256 | 86ac05db226d831d664e8e08191a412b3e4b159d14584a17e2aad042db702bde |