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

Function large_data_roundtrip

nodedb-codec/src/zstd_codec.rs:255–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253
254 #[test]
255 fn large_data_roundtrip() {
256 let line = "2024-01-15 ERROR database connection timeout host=db-prod-01 retry=3\n";
257 let data: Vec<u8> = line.as_bytes().repeat(1000);
258 let encoded = encode(&data).unwrap();
259 let decoded = decode(&encoded).unwrap();
260 assert_eq!(decoded, data);
261
262 let ratio = data.len() as f64 / encoded.len() as f64;
263 assert!(
264 ratio > 5.0,
265 "repetitive logs should compress >5x with zstd, got {ratio:.1}x"
266 );
267 }
268
269 #[test]
270 fn high_compression_level() {

Callers

nothing calls this directly

Calls 4

encodeFunction · 0.70
decodeFunction · 0.70
as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected