MCPcopy Create free account
hub / github.com/argumentcomputer/ix / write_rate

Function write_rate

crates/kernel/src/perf.rs:353–369  ·  view source on GitHub ↗
(
  out: &mut impl fmt::Write,
  label: &str,
  hits: &AtomicU64,
  misses: &AtomicU64,
)

Source from the content-addressed store, hash-verified

351}
352
353fn write_rate(
354 out: &mut impl fmt::Write,
355 label: &str,
356 hits: &AtomicU64,
357 misses: &AtomicU64,
358) -> fmt::Result {
359 let h = hits.load(Ordering::Relaxed);
360 let m = misses.load(Ordering::Relaxed);
361 let total = h + m;
362 if total == 0 {
363 return writeln!(out, "{label} (no probes)");
364 }
365 // 1-decimal rate is plenty for human reading.
366 #[allow(clippy::cast_precision_loss)]
367 let rate = (h as f64) / (total as f64) * 100.0;
368 writeln!(out, "{label} {h:>10} hits / {total:>10} total ({rate:>5.1}%)")
369}
370
371#[cfg(test)]
372mod tests {

Callers 2

write_summaryMethod · 0.85

Calls

no outgoing calls

Tested by 1