fix: cache calculation

This commit is contained in:
2026-04-15 17:31:39 +08:00
parent 365ceac3be
commit ff316c6873
23 changed files with 500 additions and 336 deletions

View File

@@ -51,7 +51,11 @@ impl TierResult {
capacity_blocks,
hits,
misses,
hit_rate: if total == 0 { 0.0 } else { hits as f64 / total as f64 },
hit_rate: if total == 0 {
0.0
} else {
hits as f64 / total as f64
},
}
}
}
@@ -68,12 +72,7 @@ pub fn analyze(records: &[RequestRecord], capacity_blocks: u64) -> OracleResult
// 1. Unlimited cache
let unlimited_hits = run_unlimited(records);
let unlimited = TierResult::from_counts(
"unlimited",
u64::MAX,
unlimited_hits,
total_blocks,
);
let unlimited = TierResult::from_counts("unlimited", u64::MAX, unlimited_hits, total_blocks);
// 2. Precompute next-use index for Belady
let next_use = build_next_use(records);