MCPcopy Create free account
hub / github.com/agenticsorg/lean-agentic / test_cache_hit_rate

Function test_cache_hit_rate

leanr-eval-lite/src/normalize.rs:323–343  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

321
322 #[test]
323 fn test_cache_hit_rate() {
324 let mut arena = Arena::new();
325 let env = Environment::new();
326 let ctx = Context::new();
327
328 let term = arena.mk_var(0);
329
330 let config = NormalizeConfig::default();
331 let mut normalizer = Normalizer::new(&mut arena, &env, config);
332
333 // First access - cache miss
334 let _ = normalizer.whnf(term, &ctx).unwrap();
335 assert_eq!(normalizer.stats().cache_misses, 1);
336
337 // Second access - cache hit
338 let _ = normalizer.whnf(term, &ctx).unwrap();
339 assert_eq!(normalizer.stats().cache_hits, 1);
340
341 let hit_rate = normalizer.cache_hit_rate();
342 assert!((hit_rate - 0.5).abs() < 0.01);
343 }
344}

Callers

nothing calls this directly

Calls 3

mk_varMethod · 0.80
whnfMethod · 0.45
cache_hit_rateMethod · 0.45

Tested by

no test coverage detected