High-resolution performance logging for Python.
Project description
📉 LogPulse
High-resolution performance logging for Python with persistent session tracking.
LogPulse is designed for developers who need to monitor execution latency across multiple, independent script runs—perfect for benchmarking RAG systems, AI Agents, and ephemeral cloud functions.
✨ Features
- ⏱️ Nanosecond Precision: Uses
time.perf_counter_ns()for the highest possible accuracy. - 💾 Persistent Sessions: Automatically tracks run IDs across script restarts using a local state.
- 🏷️ Session Tagging: Group your runs (e.g.,
gpt-4o-test,v1-prompt) for easy A/B comparison. - 📊 Built-in Visualization: One-line plotting for latency trends, distributions, and boxplots.
- ⚡ Lightweight: Zero-dependency core (Pandas only used for export/stats).
🚀 Installation
Install the core library:
pip install logpulse
Or include the visualization suite:
pip install "logpulse[viz]"
📖 Quick Start
1. Basic Logging
from logpulse import LogPulse
# Initialize (creates logs/perf_metrics.csv by default)
tracker = LogPulse(session_tag="experiment-alpha")
# Use as a decorator
@tracker.timeit("heavy_task")
def my_function():
# ... your code ...
pass
# Or as a context manager
with tracker.measure("database_query"):
# ... code to measure ...
pass
# Save results to disk
tracker.save()
2. Visualize Your Progress
Because LogPulse remembers your previous runs, you can visualize trends across time:
from logpulse.viz import PulseVisualizer
viz = PulseVisualizer()
# Compare different session tags side-by-side
viz.compare_sessions(tags=["gpt-4o-test", "gpt-3.5-test"])
# View the latency distribution (Density Plot)
viz.plot_distribution()
🛠️ Advanced Usage
Persistent Run IDs
Unlike other loggers, LogPulse stores a global state in .logpulse_state.json. If you run your script 100 times in a row, the run_id will correctly increment from 1 to 100 in your CSV, allowing for true time-series analysis of ephemeral scripts.
Clearing History
To reset the global counter and start fresh:
tracker = LogPulse()
tracker.clear_history(delete_logs=True)
📊 Comparison Strategy
LogPulse is built for RAG Evaluation. Use different session_tag values to compare:
-
Different LLM Models (GPT-4 vs Claude 3.5)
-
Different Chunk Sizes
-
Different Embedding Models
📜 License
Distributed under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logpulse-0.1.2.tar.gz.
File metadata
- Download URL: logpulse-0.1.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c016fdfad1479118af342f0397a10b0ceb74a03597149bcab32a7e9e98cb1eb1
|
|
| MD5 |
5f21e1346c72697c38ac06271dd5ba50
|
|
| BLAKE2b-256 |
5f5e80074f7bdcaf42c0e6473d7288b869e50fb1877ee59cad9983473f8f8d04
|
File details
Details for the file logpulse-0.1.2-py3-none-any.whl.
File metadata
- Download URL: logpulse-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23488972196e60fe4200813ef1c41bf32a25cf64bce6382fdb8f4f16a3c54bd4
|
|
| MD5 |
c8f4c7674612d529a42369342cb596ae
|
|
| BLAKE2b-256 |
7c0ceb11c2937b5d796232cd0ac7b64dd8058d68395cc0be99b7ef6b0d866467
|