Skip to content

Commit 45e4de2

Browse files
authored
docs: enhance benchmark documentation with value construction convention (#118)
- Added a section on value construction convention to the benchmark files, clarifying how benchmark entry points utilize `Fn(u64) -> Arc<V>` for value storage. - Emphasized the importance of using the cheapest possible payload to focus on cache policy behavior rather than allocator costs. These updates improve the clarity of benchmark usage and ensure users understand the implications of value construction on performance metrics.
1 parent 8b820b1 commit 45e4de2

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

benches/reports.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
//!
33
//! This is a standalone binary (not a criterion benchmark) that prints
44
//! human-readable comparison tables for cache policy evaluation.
5+
//!
6+
//! ## Value construction convention
7+
//!
8+
//! Benchmark entry points take a `value_for_key: Fn(u64) -> Arc<V>` so callers
9+
//! choose what to store. We pass [`Arc::new`] directly, which the compiler
10+
//! resolves to `fn(u64) -> Arc<u64>`, i.e. the value is the key itself wrapped
11+
//! in `Arc`. Cache-policy measurements (hit/miss, eviction, latency) don't
12+
//! depend on payload contents, so the cheapest possible payload keeps the
13+
//! workload focused on policy behavior rather than allocator/clone cost.
514
615
use bench_support as common;
716
use bench_support::for_each_policy;

benches/runner.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
//! JSON results to `target/benchmarks/<run-id>/results.json`.
55
//!
66
//! Run with: `cargo bench --bench runner`
7+
//!
8+
//! ## Value construction convention
9+
//!
10+
//! Benchmark entry points take a `value_for_key: Fn(u64) -> Arc<V>` so callers
11+
//! choose what to store. We pass [`Arc::new`] directly, which the compiler
12+
//! resolves to `fn(u64) -> Arc<u64>`, i.e. the value is the key itself wrapped
13+
//! in `Arc`. Cache-policy measurements (hit/miss, eviction, latency) don't
14+
//! depend on payload contents, so the cheapest possible payload keeps the
15+
//! workload focused on policy behavior rather than allocator/clone cost.
716
817
use bench_support as common;
918
use bench_support::for_each_policy;

benches/workloads.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
//! For micro-ops (get/insert latency), see: `cargo bench --bench ops`
1212
//! For policy-specific operations, see: `cargo bench --bench policy_*`
1313
//! For external crate comparison, see: `cargo bench --bench comparison`
14+
//!
15+
//! ## Value construction convention
16+
//!
17+
//! Benchmark entry points take a `value_for_key: Fn(u64) -> Arc<V>` so callers
18+
//! choose what to store. We pass [`Arc::new`] directly, which the compiler
19+
//! resolves to `fn(u64) -> Arc<u64>`, i.e. the value is the key itself wrapped
20+
//! in `Arc`. Cache-policy measurements (hit/miss, eviction, latency) don't
21+
//! depend on payload contents, so the cheapest possible payload keeps the
22+
//! workload focused on policy behavior rather than allocator/clone cost.
1423
1524
use bench_support as common;
1625
use bench_support::for_each_policy;

0 commit comments

Comments
 (0)