2022-12-12 17:39:57 +00:00
|
|
|
use std::time::Instant;
|
|
|
|
|
2023-07-31 03:49:55 +00:00
|
|
|
use loro_internal::{LoroDoc, LoroValue};
|
2023-09-02 10:19:34 +00:00
|
|
|
#[global_allocator]
|
|
|
|
static ALLOC: dhat::Alloc = dhat::Alloc;
|
2022-12-08 15:02:44 +00:00
|
|
|
|
|
|
|
fn main() {
|
2023-09-02 10:19:34 +00:00
|
|
|
let mut actors: Vec<_> = (0..1000).map(|_| LoroDoc::default()).collect();
|
2022-12-12 17:39:57 +00:00
|
|
|
let mut updates: Vec<Vec<u8>> = Vec::new();
|
2022-12-08 15:02:44 +00:00
|
|
|
for (i, actor) in actors.iter_mut().enumerate() {
|
2023-07-31 03:49:55 +00:00
|
|
|
let list = actor.get_list("list");
|
2022-12-08 15:02:44 +00:00
|
|
|
let value: LoroValue = i.to_string().into();
|
2023-07-31 03:49:55 +00:00
|
|
|
let mut txn = actor.txn().unwrap();
|
|
|
|
list.insert(&mut txn, 0, value).unwrap();
|
2023-09-02 10:19:34 +00:00
|
|
|
txn.commit().unwrap();
|
2023-07-31 03:49:55 +00:00
|
|
|
updates.push(actor.export_from(&Default::default()));
|
2022-12-08 15:02:44 +00:00
|
|
|
}
|
|
|
|
|
2023-09-02 10:19:34 +00:00
|
|
|
drop(actors);
|
2023-07-31 03:49:55 +00:00
|
|
|
|
2023-09-02 10:19:34 +00:00
|
|
|
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);
|
2022-12-08 15:02:44 +00:00
|
|
|
}
|