bench: use worst case to bench in encode

This commit is contained in:
Zixuan Chen 2023-09-07 21:42:29 +08:00
parent 1fda79402c
commit 1ce5330828
No known key found for this signature in database

View file

@ -57,17 +57,17 @@ mod run {
if !ran {
let actions = bench_utils::get_automerge_actions();
let text = loro.get_text("text");
let mut txn = loro.txn().unwrap();
for TextAction { pos, ins, del } in actions.iter() {
let mut txn = loro.txn().unwrap();
text.delete(&mut txn, *pos, *del).unwrap();
text.insert(&mut txn, *pos, ins).unwrap();
}
drop(txn);
ran = true;
}
};
let mut b = c.benchmark_group("encode");
b.sample_size(10);
b.bench_function("B4_encode_updates", |b| {
ensure_ran();
b.iter(|| {
@ -83,6 +83,16 @@ mod run {
store2.import(&buf).unwrap();
})
});
b.bench_function("B4_decode_updates detached mode", |b| {
ensure_ran();
let buf = loro.export_from(&Default::default());
b.iter(|| {
let mut store2 = LoroDoc::default();
store2.detach();
store2.import(&buf).unwrap();
})
});
b.bench_function("B4_encode_snapshot", |b| {
ensure_ran();
b.iter(|| {