Crate quantum_pulse

Crate quantum_pulse 

Source
Expand description

§Quantum Pulse - Zero-Cost Profiling Library

Zero-cost profiling 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.

Modules§

category
collector
operation
timer

Macros§

pause
Pause all active profiling timers globally
pause_stack
Pause only the timers currently on the call stack
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
unpause
Resume all paused profiling timers globally
unpause_stack
Resume timers that were paused by pause_stack!()

Structs§

NoCategory
OperationStats
PausableTimer
ProfileCollector
ProfileTimer
ProfileTimerAsync
SummaryStats

Traits§

Category
Operation

Functions§

pause_stack
Pause all timers currently on the call stack for this thread (stub)
unpause_stack
Resume all timers that were paused by pause_stack on this thread (stub)

Derive Macros§

ProfileOp
Derives the Operation trait for enums, automatically generating category implementations.