mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 21:43:59 +00:00
d942e3d7a2
* 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
60 lines
1.8 KiB
Rust
60 lines
1.8 KiB
Rust
use std::time::Instant;
|
|
|
|
use loro_internal::{LoroDoc, LoroValue};
|
|
// #[global_allocator]
|
|
// static ALLOC: dhat::Alloc = dhat::Alloc;
|
|
|
|
fn main() {
|
|
with_100k_actors_then_action();
|
|
// import_with_many_actors();
|
|
}
|
|
|
|
#[allow(unused)]
|
|
fn import_with_many_actors() {
|
|
let store = LoroDoc::default();
|
|
for i in 0..10000 {
|
|
store.set_peer_id(i);
|
|
let list = store.get_list("list");
|
|
let value: LoroValue = i.to_string().into();
|
|
let mut txn = store.txn().unwrap();
|
|
list.insert(&mut txn, 0, value).unwrap();
|
|
txn.commit().unwrap();
|
|
}
|
|
|
|
{
|
|
let start = Instant::now();
|
|
let bytes = store.export_snapshot();
|
|
LoroDoc::default().import(&bytes).unwrap();
|
|
println!("{} ms", start.elapsed().as_millis());
|
|
}
|
|
|
|
// let profiler = dhat::Profiler::builder().trim_backtraces(None).build();
|
|
// let start = Instant::now();
|
|
// let mut actor = LoroDoc::default();
|
|
// actor.import_batch(&updates).unwrap();
|
|
// println!("{} bytes", updates.iter().map(|x| x.len()).sum::<usize>());
|
|
// // dbg!(actor.get_state_deep_value());
|
|
// println!("{} ms", start.elapsed().as_millis());
|
|
// drop(profiler);
|
|
}
|
|
|
|
#[allow(unused)]
|
|
fn with_100k_actors_then_action() {
|
|
let store = LoroDoc::default();
|
|
for i in 0..100_000 {
|
|
store.set_peer_id(i);
|
|
let list = store.get_list("list");
|
|
let value: LoroValue = i.to_string().into();
|
|
let mut txn = store.txn().unwrap();
|
|
list.insert(&mut txn, 0, value).unwrap();
|
|
txn.commit().unwrap();
|
|
}
|
|
|
|
for i in 0..200_000 {
|
|
let list = store.get_list("list");
|
|
let value: LoroValue = i.to_string().into();
|
|
let mut txn = store.txn().unwrap();
|
|
list.insert(&mut txn, 0, value).unwrap();
|
|
txn.commit().unwrap();
|
|
}
|
|
}
|