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.4.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file executiontime-0.3.4.tar.gz
.
File metadata
- Download URL: executiontime-0.3.4.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 | 5e60593586dd470bd735bedddae11a3e174febe83bcd0ee7efad13ea8db8b0a1 |
|
MD5 | 1166a92b8be534bfcd0af18c79caf3b8 |
|
BLAKE2b-256 | 7d845e2d6512e10cb011767653b313eacff9a45cd6927f88fc199d948c931b4b |
File details
Details for the file executiontime-0.3.4-py3-none-any.whl
.
File metadata
- Download URL: executiontime-0.3.4-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 | 3f1defcb8a140840bc15f7305bd20697a9a58d0357780fafa76c4f21775e216d |
|
MD5 | 13f24731990197ebff8e07854344223a |
|
BLAKE2b-256 | 9244de04694f1facb2e847b4ebe8c566c9726672d28fe9d99df57659e58d1042 |