Skip to main content

📉 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.
  • � Multi-Module Smart Reuse (v0.2.0+): Detects and consolidates multiple LogPulse instances in the same execution—no counter inflation!
  • �📊 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

Multi-Module Support (v0.2.0+)

LogPulse automatically detects when multiple modules import it with the same session_tag within a single execution. Instead of inflating counters, all instances share the same run IDs and measurements list:

# module_a.py
from logpulse import LogPulse
logger = LogPulse(session_tag="my_pipeline")

# module_b.py
from logpulse import LogPulse
logger = LogPulse(session_tag="my_pipeline")  # Reuses run IDs from module_a!

# When any instance calls save(), all measurements are captured

This solves the "counter inflation" problem in multi-module projects—one execution = one accurate run count, regardless of how many modules create LogPulse instances.

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.

Metadata

Release files for logpulse 0.2.0

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

Source distribution (sdist)

Source distribution for logpulse 0.2.0
File Size Uploaded
logpulse-0.2.0.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for logpulse 0.2.0
File Interpreter ABI Platform
logpulse-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / logpulse-0.2.0.tar.gz

Download URL logpulse-0.2.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a36760100919019fe9679526fba7ca5cb11f4122890d74554fd63cc0539de8ad
BLAKE2b-256 checksum
How to use checksums
877a7557e4a509536d10fc24334e1165af51e652ec223f392fce8820b2021292
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}

Release files / logpulse-0.2.0-py3-none-any.whl

Download URL logpulse-0.2.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f151c10e575ff44fafaa80f00cff41eb68893ae572d2db83f964aff1a974f8e0
BLAKE2b-256 checksum
How to use checksums
6da52f7f310a412206189dd99642812ebd854ae7155c3e95382c07d1e692f834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

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