Skip to main content

sag_py_execution_time_decorator

Maintainability Coverage Status Known Vulnerabilities

A decorator for methods to log the execution time (sync and async)

What it does

  • Logs the execution time in milliseconds

Sample log entry:

decorated_sync_method took 1000 ms.

The entry contains "function_name" and "execution_time" as extra data.

Installation

pip install sag-py-execution-time-decorator

How to use

Decorate your methods like that:

from sag_py_execution_time_decorator.execution_time_decorator import log_execution_time

@log_execution_time()
def decorated_sync_method(param: str) -> str:
    time.sleep(SLEEP_TIME_MS / 1000)
    return f"test: {param}"


@log_execution_time(log_level=logging.ERROR, log_params=("param",))
async def decorated_async_method(param: str) -> str:
    await asyncio.sleep(SLEEP_TIME_MS / 1000)
    return f"test: {param}"

Optional arguments:

Argument Description Default
log_level The log level integar. Use logging.* constants logging.INFO
logger_name The name of the logger that is internally used for logging.getLogger execution_time_decorator
log_params A tuple of parameter names to be logged with their values in 'extra' ()

How to start developing

With vscode

Just install vscode with dev containers extension. All required extensions and configurations are prepared automatically.

With pycharm

  • Install latest pycharm
  • Install pycharm plugin Mypy
  • Configure the python interpreter/venv
  • pip install requirements-dev.txt
  • Restart pycharm

How to publish

  • Update the version in setup.py and commit your change
  • Create a tag with the same version number
  • Let github do the rest

How to test

To avoid publishing to pypi unnecessarily you can do as follows

  • Tag your branch however you like
  • Use the chosen tag in the requirements.txt-file of the project you want to test this library in, eg. sag_py_execution_time_decorator==<your tag>
  • Rebuild/redeploy your project

Metadata

Release files for sag-py-execution-time-decorator 2.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sag-py-execution-time-decorator 2.1.4
File Size Uploaded Provenance Actions
sag_py_execution_time_decorator-2.1.4.tar.gz 5.9 kB Without provenance Details for sag_py_execution_time_decorator-2.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sag-py-execution-time-decorator 2.1.4
File Interpreter ABI Platform Actions
sag_py_execution_time_decorator-2.1.4-py3-none-any.whl Python 3 none any Details for sag_py_execution_time_decorator-2.1.4-py3-none-any.whl

Total release size: 11.6 kB

Release files / sag_py_execution_time_decorator-2.1.4.tar.gz

Download URL sag_py_execution_time_decorator-2.1.4.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dd47f29fc696863beae2cc235f15d45f6859717cff6f274b8625b3a1fbae83ec
BLAKE2b-256 checksum
How to use checksums
9b69b2df8c76b46ea718bab9348956f53a9578a53e3f6dbe2008d60c5eccb390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / sag_py_execution_time_decorator-2.1.4-py3-none-any.whl

Download URL sag_py_execution_time_decorator-2.1.4-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5d04cf5927c1852932e675e791de65ff377cd83b2d6cdcd208d12b4dbe182ed
BLAKE2b-256 checksum
How to use checksums
81126eb22a9ca73a1cb1030a3cb56274a9e037aefff0f89f62f36c37d9ad5ffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for sag-py-execution-time-decorator 2.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page