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

Function f64_compression_ratio

nodedb-codec/src/pcodec.rs:167–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

165
166 #[test]
167 fn f64_compression_ratio() {
168 // Pcodec should compress numerical data better than raw.
169 let mut values = Vec::with_capacity(10_000);
170 let mut rng: u64 = 42;
171 for _ in 0..10_000 {
172 rng = rng.wrapping_mul(6364136223846793005).wrapping_add(1);
173 values.push(((rng >> 33) as f64 / (u32::MAX as f64)) * 1000.0);
174 }
175 let encoded = encode_f64(&values).unwrap();
176 let raw_size = values.len() * 8;
177 let ratio = raw_size as f64 / encoded.len() as f64;
178 assert!(
179 ratio > 1.1,
180 "pcodec should compress random-ish floats >1.1x, got {ratio:.2}x"
181 );
182 }
183
184 #[test]
185 fn i64_empty() {

Callers

nothing calls this directly

Calls 3

encode_f64Function · 0.70
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected