Skip to main content

TimeGuardian is a package for execution time measurement

Project description

TimeGuardian

TimeGuardian is a Python package designed for measuring and logging the execution time and memory usage of functions. This package is particularly useful for performance monitoring and optimization in Python applications.

Features

  • Decorators for timing functions and logging memory usage.
  • Customizable logging for execution time and memory usage with rich formatting.
  • Conditional logging based on execution time and memory usage thresholds.

Installation

Install TimeGuardian directly from pip:

pip install timeguardian

Or, install from the source code:

cd path/to/TimeGuardian
pip install .

Usage

Import TimeGuardian from the timeguardian package and use it as a decorator on your functions to measure their execution time and memory usage.

Basic Usage

from timeguardian import TimeGuardian

# To measure execution time and/or memory usage
@TimeGuardian.measure
def my_function():
    # function implementation

# Custom name logging
@TimeGuardian.measure(name="CustomName")
def another_function():
    # function implementation


# Custom logging with name, time and memory
@TimeGuardian.measure(name="CustomName", elapsed=True, memory=True) #(elapsed in ms, memory in bytes)
def another_function():
    # function implementation

Advanced Usage

Monitor performance with conditional logging:

from timeguardian import TimeGuardian

# Monitor and log only if execution time or memory usage exceeds the specified limits (time in ms, memory in bytes)
@TimeGuardian.monitor(elapsed=200, memory=1024)
def monitored_function():
    # function implementation

Contributing

Contributions to TimeGuardian are welcome!

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

timeguardian-0.0.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

timeguardian-0.0.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file timeguardian-0.0.5.tar.gz.

File metadata

  • Download URL: timeguardian-0.0.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for timeguardian-0.0.5.tar.gz
Algorithm Hash digest
SHA256 01d9bac75cd98415d88f71992dd649d7e027105843c2cb8cbe058e0bb657b9ec
MD5 c7be6a4f5b321d6d9f4622b5735f1bb8
BLAKE2b-256 6ef810054e28e25a37c15a8b434289cc31ef48fa8aef194b19442dc20af52fa0

See more details on using hashes here.

File details

Details for the file timeguardian-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for timeguardian-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 445cbe3cd7ea8de88d840e60c638e1659649cbec89ac8ff83daa194589ea8b6a
MD5 d7fb042b0a42ea4985ae97263122028b
BLAKE2b-256 f94902d4a3b280284f770031b0df1b3dc4a997ea15f2c1d1d97a64c57c8a466e

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