v0.4.0 — Performance, Verified
Pre-release
Pre-release
v0.4.0 — Performance, Verified
The "zero-overhead" claim that has been quietly sitting in the README since day one now ships with the numbers to back it up. clock-lib 0.4.0 adds a real benchmark suite and a docs/PERFORMANCE.md report that proves the wrapper costs the same as std::time — not "approximately the same", measurably the same.
Highlights
- Real benchmark suite. Seven
criteriongroups inbenches/clock_bench.rscovering monotonic readings, wall readings, unix conversions, the unix helpers end-to-end, elapsed-time measurement, everyManualClockoperation, and trait-object dispatch through&dyn Clock. - Zero overhead, verified.
docs/PERFORMANCE.mdrecords the recorded median for every bench alongside the rawstd::timecall it forwards to. The wrapper functions sit on top of the bare std functions inside criterion's noise band. - Committed baseline. Run
cargo bench --bench clock_bench -- --save-baseline 0.4.0to pin the current numbers, thencargo bench --bench clock_bench -- --baseline 0.4.0after any change to detect regressions. - Hot-path methodology written down. What was measured, how, on what hardware, and how to reproduce it locally — all in the performance doc.
What's New
Added
benches/clock_bench.rs— real benchmarks across seven groups:monotonic_now—Instant::nowvsclock_lib::now,Monotonic::now,SystemClock::now.wall_now—SystemTime::nowvsclock_lib::wall,Wall::now.unix_conversions— cost ofWall::unix_seconds/unix_millis/unix_nanoson a pre-captured reading.unix_helpers— end-to-end cost ofclock_lib::unix/unix_ms/unix_ns.elapsed—Instant::elapsedvsMonotonic::elapsedvsclock_lib::elapsed.manual_clock—now,wall,offset,advance(1ns).dyn_dispatch— concreteSystemClockvs&dyn Clock.
docs/PERFORMANCE.md— methodology, recorded numbers, the zero-overhead claim, and how to compare against the baseline.- README link to the performance document.
Changed
- Replaced the placeholder bench function with the real suite.
Compatibility
- MSRV: Rust 1.85 (unchanged)
- Edition: 2024 (unchanged)
- Public API: unchanged — no migration required from 0.3.x.
Upgrading From 0.3.x
[dependencies]
clock-lib = "0.4"No code changes required.
What's Next
- 0.5.0 —
no_stdhardening and the 1.0 release candidate. - 1.0.0 — stable.
Full Changelog: v0.3.0...v0.4.0