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

Function repeated_bytes

nodedb-codec/src/rans.rs:353–365  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

351
352 #[test]
353 fn repeated_bytes() {
354 let data = vec![0u8; 10_000];
355 let encoded = encode(&data);
356 let decoded = decode(&encoded).unwrap();
357 assert_eq!(decoded, data);
358
359 // Highly repetitive → near-zero entropy → excellent compression.
360 let ratio = data.len() as f64 / encoded.len() as f64;
361 assert!(
362 ratio > 2.0,
363 "repeated bytes should compress >2x, got {ratio:.1}x"
364 );
365 }
366
367 #[test]
368 fn text_data() {

Callers

nothing calls this directly

Calls 3

encodeFunction · 0.70
decodeFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected