2022-11-14 02:49:42 +00:00
|
|
|
#[cfg(not(feature = "test_utils"))]
|
2022-11-09 03:04:58 +00:00
|
|
|
fn main() {}
|
|
|
|
|
2022-11-14 02:49:42 +00:00
|
|
|
#[cfg(feature = "test_utils")]
|
2022-11-09 03:04:58 +00:00
|
|
|
fn main() {
|
2022-12-27 06:18:46 +00:00
|
|
|
use std::time::Instant;
|
2022-11-09 03:04:58 +00:00
|
|
|
|
2022-12-27 06:18:46 +00:00
|
|
|
use bench_utils::{get_automerge_actions, TextAction};
|
2023-02-27 12:55:52 +00:00
|
|
|
use loro_internal::{LoroCore, Transact};
|
2022-11-09 03:04:58 +00:00
|
|
|
|
2022-12-27 06:18:46 +00:00
|
|
|
let actions = get_automerge_actions();
|
2022-11-09 03:04:58 +00:00
|
|
|
let mut loro = LoroCore::default();
|
|
|
|
let mut loro_b = LoroCore::default();
|
2022-11-09 09:54:06 +00:00
|
|
|
let mut loro_c = LoroCore::default();
|
2022-11-09 04:18:27 +00:00
|
|
|
let start = Instant::now();
|
2022-12-27 06:18:46 +00:00
|
|
|
for (i, TextAction { pos, ins, del }) in actions.iter().enumerate() {
|
2022-11-11 07:23:22 +00:00
|
|
|
let mut text = loro.get_text("text");
|
2023-02-27 12:55:52 +00:00
|
|
|
{
|
|
|
|
let txn = loro.transact();
|
|
|
|
text.delete(&txn, *pos, *del).unwrap();
|
|
|
|
text.insert(&txn, *pos, ins).unwrap();
|
|
|
|
}
|
2022-11-11 07:23:22 +00:00
|
|
|
let mut text = loro_b.get_text("text");
|
2023-02-27 12:55:52 +00:00
|
|
|
{
|
|
|
|
let txn = loro_b.transact();
|
|
|
|
text.delete(&txn, *pos, *del).unwrap();
|
|
|
|
text.insert(&txn, *pos, ins).unwrap();
|
|
|
|
}
|
|
|
|
|
2022-11-09 09:54:06 +00:00
|
|
|
if i % 10 == 0 {
|
2022-12-12 17:39:57 +00:00
|
|
|
loro.import(loro_b.export(loro.vv_cloned()));
|
|
|
|
loro_b.import(loro.export(loro_b.vv_cloned()));
|
2022-11-09 06:11:06 +00:00
|
|
|
}
|
2022-11-09 03:04:58 +00:00
|
|
|
}
|
2022-11-09 05:53:12 +00:00
|
|
|
loro_b.debug_inspect();
|
|
|
|
loro.debug_inspect();
|
2022-11-09 04:18:27 +00:00
|
|
|
println!("Elapsed {}ms", start.elapsed().as_millis());
|
2022-12-12 17:39:57 +00:00
|
|
|
loro_c.import(loro.export(loro_c.vv_cloned()));
|
2022-11-09 09:54:06 +00:00
|
|
|
println!("Elapsed {}ms", start.elapsed().as_millis());
|
2022-11-09 03:04:58 +00:00
|
|
|
}
|