Skip to main content

A Python package with some simple wrapper functions to print the execution time of methods

Project description

PyPI license PyPI version PyPI pyversions Downloads

Execution Time Wrapper

A simple package with a few method to get the execution time of methods through wrapping.

Usage

Currently, the package contains two methods, one which returns to sdout (print) and one which goes to a logger. The method prints the time in a nice way, i.e. milliseconds, seconds, minutes or hours. For example:

from execution_time_wrapper import get_execution_time_print, get_execution_time_log

@get_execution_time_print
def my_fun():
    print("Hello World!")
my_fun()
>> Hello World!
>> Computation time for my_fun: 0.02 ms

However, if the function takes more time:

from execution_time_wrapper import get_execution_time_print, get_execution_time_log
from time import sleep

@get_execution_time_print
def my_fun():
    sleep(4)
    print("Hello World!")
my_fun()
>> Hello World!
>> Computation time for my_fun: 4.00 s

The same for the other method given, i.e. get_execution_time_log.

TODOs

[ ] Implement logger level

@2022, Leonardo Alchieri

People-Centered Computing Lab - Università della Svizzera italiana, Switzerland

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

execution_time_wrapper-1.0.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file execution_time_wrapper-1.0.1.tar.gz.

File metadata

File hashes

Hashes for execution_time_wrapper-1.0.1.tar.gz
Algorithm Hash digest
SHA256 a2389b95b7158bb598eede4402cdce3c8b717411023bc1abc1ae1950089634dc
MD5 ef8ed01abfbfa0fd9376c73d6ccf00c2
BLAKE2b-256 7516a5d631fdc76f8ea0ef2a152fc327eb95926c8ab0ded92b9adeffcae0a343

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