mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 12:25:03 +00:00
6950e42cae
* perf: optimize snapshot encoding * perf: rm id_int_map and boost speed 1.4x Co-authored-by: Leon Zhao <leeeon233@gmail.com> --------- Co-authored-by: Leon Zhao <leeeon233@gmail.com>
28 lines
865 B
Rust
28 lines
865 B
Rust
use loro_internal::LoroDoc;
|
|
|
|
fn main() {
|
|
use bench_utils::TextAction;
|
|
use std::time::Instant;
|
|
|
|
let actions = bench_utils::get_automerge_actions();
|
|
let loro = LoroDoc::default();
|
|
let start = Instant::now();
|
|
// loro.subscribe_deep(Box::new(|_| ()));
|
|
let text = loro.get_text("text");
|
|
let n = 100;
|
|
for _ in 0..n {
|
|
let mut txn = loro.txn().unwrap();
|
|
for TextAction { del, ins, pos } in actions.iter() {
|
|
text.delete_with_txn(&mut txn, *pos, *del).unwrap();
|
|
text.insert_with_txn(&mut txn, *pos, ins).unwrap();
|
|
}
|
|
}
|
|
println!("Apply time {}", start.elapsed().as_millis());
|
|
loro.diagnose_size();
|
|
drop(actions);
|
|
let start = Instant::now();
|
|
for _ in 0..1 {
|
|
loro.export_snapshot();
|
|
}
|
|
println!("Snapshot encoding time {}", start.elapsed().as_millis());
|
|
}
|