mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
test: add size test for update encoding
This commit is contained in:
parent
7adc399605
commit
89ae18e87c
2 changed files with 12 additions and 19 deletions
|
@ -1,6 +1,9 @@
|
|||
use std::{io::Read, time::Instant};
|
||||
use std::{
|
||||
io::{Read, Write},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use flate2::read::GzDecoder;
|
||||
use flate2::{read::GzDecoder, write::GzEncoder};
|
||||
use loro_core::{configure::Configure, container::registry::ContainerWrapper, LoroCore};
|
||||
use serde_json::Value;
|
||||
const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz");
|
||||
|
@ -47,20 +50,10 @@ fn main() {
|
|||
assert_eq!(buf, buf2);
|
||||
let json2 = loro.to_json();
|
||||
assert_eq!(json1, json2);
|
||||
let mut last = 100;
|
||||
let mut count = 0;
|
||||
let mut max_count = 0;
|
||||
for &byte in buf.iter() {
|
||||
if byte == last {
|
||||
count += 1;
|
||||
if count > max_count {
|
||||
max_count = count;
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
last = byte;
|
||||
}
|
||||
|
||||
println!("Longest continuous bytes length {}", max_count);
|
||||
let update_buf = loro.export_updates(&Default::default()).unwrap();
|
||||
println!("Updates have {} bytes", update_buf.len());
|
||||
let mut encoder = GzEncoder::new(Vec::new(), flate2::Compression::default());
|
||||
encoder.write_all(&update_buf).unwrap();
|
||||
let data = encoder.finish().unwrap();
|
||||
println!("After compress updates have {} bytes", data.len());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ pub struct GcConfig {
|
|||
impl Default for GcConfig {
|
||||
fn default() -> Self {
|
||||
GcConfig {
|
||||
gc: true,
|
||||
gc: false,
|
||||
snapshot_interval: 6 * MONTH,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue