loro/crates/compact-bytes/examples/permuted.rs
Zixuan Chen 6311782943 perf: optimize compress & speed
but no cap for now
2023-07-13 22:43:02 +08:00

12 lines
522 B
Rust

use compact_bytes::CompactBytes;
pub fn main() {
let data = include_str!("../benches/permuted.mht");
// this simulate the situation in loro snapshot encoding,
// where we first encode the state snapshot, then we look up the slices of the ops.
let mut bytes = CompactBytes::new();
bytes.append(&data.as_bytes()[..data.len() / 2]);
println!("{}", bytes.as_bytes().len()); // 114275
bytes.alloc_advance(&data.as_bytes()[data.len() / 2..]);
println!("{}", bytes.as_bytes().len()); // 117026
}