MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_streaming_topk_stats

Function test_streaming_topk_stats

graphlite/src/exec/streaming_topk.rs:353–371  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351
352 #[test]
353 fn test_streaming_topk_stats() {
354 let mut topk = StreamingTopK::new(5);
355
356 for i in 0..20 {
357 topk.add(create_test_row(i, i as f64), i as f64);
358 }
359
360 let stats = topk.stats();
361
362 assert_eq!(stats.processed_count, 20);
363 assert_eq!(stats.kept_count, 5);
364 assert_eq!(stats.k, 5);
365
366 // Memory savings: kept 5 out of 20 = 25%
367 assert!((stats.memory_savings_ratio() - 0.25).abs() < 0.01);
368
369 // Discard ratio: discarded 15 out of 20 = 75%
370 assert!((stats.discard_ratio() - 0.75).abs() < 0.01);
371 }
372
373 #[test]
374 fn test_streaming_topk_empty() {

Callers

nothing calls this directly

Calls 3

create_test_rowFunction · 0.70
addMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected