loro/crates/loro-internal/examples/automerge_x100.rs

34 lines
1.1 KiB
Rust
Raw Normal View History

use loro_internal::LoroDoc;
2022-12-02 06:39:51 +00:00
fn main() {
2022-12-27 06:18:46 +00:00
use bench_utils::TextAction;
use std::time::Instant;
2022-12-02 06:39:51 +00:00
2022-12-27 06:18:46 +00:00
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 {
Feat: Peritext-like rich text support (#123) * feat: richtext wip * feat: add insert to style range map wip * feat: richtext state * fix: fix style state inserting and style map * fix: tiny vec merge err * fix: comment err * refactor: use new generic-btree & refine impl * feat: fugue tracker * feat: tracker * feat: tracker * fix: fix a few err in impl * feat: init richtext content state * feat: refactor arena * feat: extract anchor_type info out of style flag * refactor: state apply op more efficiently we can now reuse the repr in state and op * fix: new clippy errors * refactor: use state chunk as delta item * refactor: use two op to insert style start and style end * feat: diff calc * feat: handler * fix: tracker checkout err * fix: pass basic richtext handler tests * fix: pass handler basic marking tests * fix: pass all peritext criteria * feat: snapshot encoding for richtext init * refactor: replace Text with Richtext * refacotr: rm text code * fix: richtext checkout err * refactor: diff of text and map * refactor: del span * refactor: event * fix: fuzz err * fix: pass all tests * fix: fuzz err * fix: list child cache err * chore: rm debug code * fix: encode enhanced err * fix: encode enchanced * fix: fix several richtext issue * fix: richtext anchor err * chore: rm debug code * fix: richtext fuzz err * feat: speedup text snapshot decode * perf: optimize snapshot encoding * perf: speed up decode & insert * fix: fugue span merge err * perf: speedup delete & id cursor map * fix: fugue merge err * chore: update utils * perf: speedup text insert / del * fix: cursor cache * perf: reduce conversion by introducing InsertText * perf: speed up by refined cursor cache * chore: update gbtree dep * refactor(wasm): use quill delta format * chore: fix warnings
2023-10-29 06:02:13 +00:00
let mut txn = loro.txn().unwrap();
2022-12-27 06:18:46 +00:00
for TextAction { del, ins, pos } in actions.iter() {
2023-11-28 08:22:43 +00:00
text.delete_with_txn(&mut txn, *pos, *del).unwrap();
text.insert_with_txn(&mut txn, *pos, ins).unwrap();
2022-12-02 06:39:51 +00:00
}
}
println!("Apply time {}", start.elapsed().as_millis());
loro.diagnose_size();
drop(actions);
let start = Instant::now();
let snapshot = loro.export_snapshot();
println!("Snapshot encoding time {}", start.elapsed().as_millis());
let compressed = zstd::encode_all(&mut snapshot.as_slice(), 0).unwrap();
println!(
"Snapshot encoding time including compression {}",
start.elapsed().as_millis()
);
println!("Snapshot size {}", snapshot.len());
println!("Snapshot size after compression {}", compressed.len());
2022-12-02 06:39:51 +00:00
}