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
Built Distribution
File details
Details for the file timeguardian-0.0.4.tar.gz
.
File metadata
- Download URL: timeguardian-0.0.4.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca2dcbf9de76c63aca9d74ee32177904680ef7cec005af5df76810c482e4109a |
|
MD5 | e965f1eddc5e8e3db13a8d049b3b6073 |
|
BLAKE2b-256 | 044559fd56535e030c026a0f611ce496787a73317968a976b102ba4b22bbf02c |
File details
Details for the file timeguardian-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: timeguardian-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7a319465a7849d7c9abdae812804ad679367c8cb61b89425045a768055fdbdf |
|
MD5 | 8ca4a48352e18b7f3aec01878f7ccc58 |
|
BLAKE2b-256 | 49112614f3dbcc924cd89401ab04281367c2137ebebd81887d957d033dd6a2ff |