Repository navigation
Benchmark v0.6.0 - stable
Pre-release
Pre-release
Version 0.6.0 - 2025-08-29
A production-focused release introducing advanced observability features, hardening thread safety guarantees, and expanding platform coverage. This release maintains zero-overhead promises while adding powerful production metrics capabilities.
✨ Features
- Production metrics system with
Watch,Timer, andstopwatch!macro for live observability. - Zero-dependency histogram implementation for percentile calculations (p50/p95/p99).
- Enhanced thread safety with RwLock-based collectors and atomic operations throughout.
- Expanded platform matrix with verified support for tier-1 and tier-2 targets.
- Assembly artifacts now include full disassembly comparisons for enabled vs disabled builds.
💡 Highlights
WatchAPI: Thread-safe production metrics collector with nanosecond precision and built-in histogram for percentiles.Timerguard: RAII pattern that auto-records on drop, perfect for scope-based timing.stopwatch!macro: Zero-boilerplate production timing - just wrap your code.- Feature reorganization: New
standardandminimalfeature presets for common use cases. - Saturating arithmetic: All numeric operations now use saturating variants to prevent panics on overflow.
- Drop safety:
Timerguarantees exactly-once recording even during stack unwinding.
📌 Changes
Added
- Production metrics:
Watch,Timer, andstopwatch!undermetricsfeature.- Histogram implementation: Zero-dependency percentile calculations with configurable buckets.
- Feature presets:
standard(all common features) andminimal(core timing only).- CI coverage: Tier-2 platform testing including
wasm32-unknown-unknown.- Assembly inspection: Enhanced with full function-level disassembly comparisons.
Changes
- Thread safety: All shared state now uses
RwLockwith minimal hold times.- Numeric safety: Converted all arithmetic to saturating operations.
- API refinement:
Collector::record(&Measurement)signature is now stable.- Documentation: Added production metrics guide and expanded async examples.
𖢥 Bug Fixes
- Percentile clamping: Out-of-range queries (e.g., 1.2) now safely clamp to [0.0, 1.0].
- Empty dataset handling:
Watch::snapshot()returns zeros instead of panicking. - Drop guard:
Timernow storesOption<Instant>to prevent double-record edge cases. - Overflow protection: 128-bit nanosecond storage prevents accumulator overflow in long-running processes.
Minimum Supported Rust Version (MSRV)
1.75.0
Migration Notes
- New features available: Enable
features = ["metrics"]for production observability tools. - Feature presets: Replace
features = ["std", "benchmark", "metrics"]withfeatures = ["standard"]. - No breaking changes: If you're on 0.5.0, just bump the version - all APIs remain compatible.
Production Metrics Quick Start
use benchmark::{Watch, Timer, stopwatch};
// Create a thread-safe metrics collector
let watch = Watch::new();
// Method 1: RAII Timer
{
let _timer = Timer::new(watch.clone(), "db.query");
// ... work is timed until drop ...
}
// Method 2: Macro
stopwatch!(watch, "api.request", {
// ... work to measure ...
});
// Get percentiles and stats
let snapshot = watch.snapshot();
let stats = &snapshot["db.query"];
println!("p99 latency: {} ms", stats.percentile(0.99).unwrap().as_millis());CI Overview
- Cross-platform matrix: Linux, macOS, Windows + tier-2 targets.
- Zero-overhead verification: Binary size comparison and assembly inspection.
- Thread safety validation: Miri and thread sanitizer coverage.
- Production simulation: Benchmarks include concurrent
Watchoperations. - Feature matrix: All combinations tested including
no_stdbuilds. - Documentation: Builds with warnings-as-errors and tests all examples.
Performance Characteristics
- Disabled overhead: 0 bytes, 0 nanoseconds (verified by CI).
- Timing overhead: ~80ns per measurement (on par with raw
Instant). - Watch recording: ~200ns per record with lock contention handling.
- Percentile queries: O(1) after initial histogram population.
- Memory usage: Fixed ~32KB per histogram (1024 buckets × 32 bytes).
Known Notes
- Histogram buckets are pre-allocated (1024) for consistent memory usage.
- Percentile accuracy depends on value distribution; extreme outliers may be approximated.
- Timer drop during panic records the elapsed time (intended behavior for observability).
- Watch is designed for production metrics, not microbenchmarking - use
benchmark!for development.
Full Changelog: v0.5.0...v0.6.0