Skip to main content

Utilities to show execution time during development of a module

Project description

executiontime

License: MIT

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


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.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

executiontime-0.3.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file executiontime-0.3.1.tar.gz.

File metadata

  • Download URL: executiontime-0.3.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

File hashes

Hashes for executiontime-0.3.1.tar.gz
Algorithm Hash digest
SHA256 db9729abeae7161610b4d80e80b4bf4063f1eb9c0e8cb4be68a01eb497d069ff
MD5 f1d85614b59b601ee54867d2aac07ee0
BLAKE2b-256 7154425219fd7a4e1a0c78e7b101ef61cbe17d32d83775f2acfaf9c4830a0294

See more details on using hashes here.

File details

Details for the file executiontime-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: executiontime-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

File hashes

Hashes for executiontime-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a93c62c0ac3b6f3917f01d72e7e9e23a3d4f8d57497ed119399c694d6d112040
MD5 b8dd413823bcb71a16162e640d8a7e8e
BLAKE2b-256 d461134fd47436737ff87ad4e2ec44721173beb555ff3bdd63d908bb9c98f33f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page