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.3.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for executiontime-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 260e0ec6638b21c7a66972dd2b65aecff30c01e5f84d0a8adec7773d58fc68d4 |
|
MD5 | 923c54dc6fb8b7c317c21574cbebe4f7 |
|
BLAKE2b-256 | 5b2fcb0618ff6dd3c6b51ff82ea6c5910132e63945d09ee3411d0e911f45dc1a |