MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / compression_ratio

Function compression_ratio

nodedb-codec/src/gorilla.rs:476–493  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

474
475 #[test]
476 fn compression_ratio() {
477 let mut enc = GorillaEncoder::new();
478 let mut rng_state: u64 = 12345;
479 for i in 0..10_000 {
480 rng_state = rng_state.wrapping_mul(6364136223846793005).wrapping_add(1);
481 let jitter = ((rng_state >> 33) as f64) / (u32::MAX as f64) * 2.0 - 1.0;
482 let value = 50.0 + jitter * 5.0;
483 enc.encode(1_700_000_000_000 + i * 10_000, value);
484 }
485 let data = enc.finish();
486
487 let raw_size = 10_000 * 16;
488 let ratio = raw_size as f64 / data.len() as f64;
489 assert!(
490 ratio > 2.0,
491 "compression ratio {ratio:.1}:1 too low (expected >2:1)"
492 );
493 }
494}

Callers

nothing calls this directly

Calls 3

encodeMethod · 0.45
finishMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected