Skip to main content

The ececy exec_time decorator is a utility that measures the execution time of a function. It can be used to easily track and log the time taken by a function to execute, both for synchronous and asynchronous functions.

Project description

Execy

Upload Python Package

The execy @exec_time decorator is a utility that measures the execution time of a function. It can be used to easily track and log the time taken by a function to execute, both for synchronous and asynchronous functions.

Table of Contents

Installation

pip install execy

Usage

To use the exec_time decorator, follow these steps:

from execy import exec_time
import asyncio
import time

@exec_time
def sync_function():
    # Simulate a time-consuming synchronous task
    time.sleep(2)

@exec_time
async def async_function():
    # Simulate a time-consuming asynchronous task
    await asyncio.sleep(2)

# Call the decorated synchronous function
sync_function()

# Call the decorated asynchronous function
asyncio.run(async_function())

The result will be

Function 'sync_function' executed in 2.0001089572906494 seconds.
Function 'async_function' executed in 2.001432180404663 seconds.

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

execy-0.1.9.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

execy-0.1.9-py3-none-any.whl (2.8 kB view hashes)

Uploaded Python 3

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