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

Function counter_with_small_increments

nodedb-codec/src/delta.rs:286–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

284
285 #[test]
286 fn counter_with_small_increments() {
287 // Request count: increment by 1 each step.
288 let values: Vec<i64> = (0..10_000).collect();
289 let encoded = encode(&values);
290 let decoded = decode(&encoded).unwrap();
291 assert_eq!(decoded, values);
292
293 // Delta = 1 → zigzag(1) = 2 → 1 byte each.
294 let bytes_per_sample = encoded.len() as f64 / values.len() as f64;
295 assert!(
296 bytes_per_sample < 2.0,
297 "unit-increment counter should compress to <2 bytes/sample, got {bytes_per_sample:.2}"
298 );
299 }
300
301 #[test]
302 fn counter_reset() {

Callers

nothing calls this directly

Calls 4

collectMethod · 0.80
encodeFunction · 0.70
decodeFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected