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=100, memory=5000) #(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.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

timeguardian-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: timeguardian-0.0.3.tar.gz
  • Upload date:
  • Size: 5.3 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.3.tar.gz
Algorithm Hash digest
SHA256 7b5dc532519afc2761609852b94529c9d7702fd527c8f7208c77c2d31925156a
MD5 96e3bf0f0067e38b2338d43eee5ece15
BLAKE2b-256 aa6b6a1e19cc35b1db3712a569cb22a644085e10e8bfc45dba5d086ecfca734a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for timeguardian-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f4adfc433511093db7e74297f288bad651768b4f3221c105c0b8a8858f2ff84
MD5 cb29b7b26a6ad999ed3ca24b5c3e90b2
BLAKE2b-256 1b2e65b9a9ba79d97fa49d9f4f750f8f0af8213b5704143e81c71085202fcbf1

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