HotPath
A lightweight Rust performance measurement library with async background processing.
Features
- Zero-overhead function measurement with
#[measure]attribute - Async background processing via MPSC channels
- Full module path tracking (e.g.,
my_app::services::db::connect) - High-performance with RwLock for concurrent access
- Graceful shutdown with proper resource cleanup
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
= { = "1.0", = ["full"] }
Usage
use ;
use Duration;
async
async
Output:
[HotPath] my_app::sync_function took 105.0ms
[HotPath] my_app::async_function took 152.1ms
[HotPath] Background task shutting down
How It Works
#[measure]- Proc-macro that wraps functions with timing code- Background MPSC - Measurements are sent to a background task via unbounded channel
- Non-blocking - Function execution continues immediately after sending measurement
- Async processing - Background task prints measurements without blocking your code
API
HotPath::init()
Starts the background measurement processing task. Call once at application startup.
HotPath::finalize()
Gracefully shuts down the background task, processing any remaining measurements. Call before application exit.
#[measure]
Attribute macro that instruments functions to send timing measurements to the background processor.