Expand description
§Quantum Pulse - Zero-Cost Profiling Library
A profiling library that provides true zero-cost abstractions through compile-time feature selection. When disabled, all profiling code compiles to nothing.
§Architecture
This library provides two implementations:
- Stub (default): Empty implementations that compile away completely
- Full (opt-in): Complete profiling with HDR histograms and reporting
Both implementations expose the exact same API, allowing you to write clean, unconditional code that works in both development and production.
§Features
- True Zero-Cost: Stub implementations are inlined and eliminated by the optimizer
- Type-Safe Categories: Define custom categories with compile-time guarantees
- Percentile Statistics: Accurate p50, p95, p99, p99.9 using HDR histograms (full mode)
- Clean API: No conditional compilation needed in your code
- Async Support: Full support for async/await patterns
- Thread-Safe: Safe to use from multiple threads
§Quick Start
use quantum_pulse::{ProfileCollector, Category, profile, operation::SimpleOperation};
// Your code always looks the same, regardless of features
let op = SimpleOperation::new("database_query");
let result = profile!(op, {
// expensive_database_query()
42
});
// With default features (stub): compiles to just the operation
// With "full" feature: includes timing and statistics
// Generate a report (empty in stub mode, full in full mode)
let report = ProfileCollector::get_summary();
println!("{:?}", report);
§Zero-Cost Guarantee
When the “full” feature is not enabled, all methods have empty bodies that are marked for inlining. The compiler’s optimizer completely removes these calls, resulting in zero runtime overhead and minimal binary size impact.
Re-exports§
pub use category::Category;
pub use category::NoCategory;
pub use collector::OperationStats;
pub use collector::ProfileCollector;
pub use collector::SummaryStats;
pub use operation::Operation;
pub use timer::PausableTimer;
pub use timer::ProfileTimer;
pub use timer::ProfileTimerAsync;
Modules§
Macros§
- profile
- Profile a code block using RAII timer
- profile_
async - Profile an async code block using RAII timer
- scoped_
timer - Create a scoped timer that records on drop