mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 13:39:12 +00:00
82b5f8dc90
* perf: remove unused transact field * perf: micro optimization * bench: fix bench * bench: add utf16 bench * chore: refine diagnose * perf: speedup utf16 lookup * perf: use better utf16 len counter * refactor: use js to cast Loro/Transaction * refactor: map and list use __loro and __txn * test: configure ci vitest * chore: ci
40 lines
1.3 KiB
Rust
40 lines
1.3 KiB
Rust
#[cfg(not(feature = "test_utils"))]
|
|
fn main() {}
|
|
|
|
#[cfg(feature = "test_utils")]
|
|
fn main() {
|
|
use std::time::Instant;
|
|
|
|
use bench_utils::{get_automerge_actions, TextAction};
|
|
use loro_internal::{LoroCore, Transact};
|
|
|
|
let actions = get_automerge_actions();
|
|
let mut loro = LoroCore::default();
|
|
let mut loro_b = LoroCore::default();
|
|
let mut loro_c = LoroCore::default();
|
|
let start = Instant::now();
|
|
for (i, TextAction { pos, ins, del }) in actions.iter().enumerate() {
|
|
let mut text = loro.get_text("text");
|
|
{
|
|
let txn = loro.transact();
|
|
text.delete(&txn, *pos, *del).unwrap();
|
|
text.insert(&txn, *pos, ins).unwrap();
|
|
}
|
|
let mut text = loro_b.get_text("text");
|
|
{
|
|
let txn = loro_b.transact();
|
|
text.delete(&txn, *pos, *del).unwrap();
|
|
text.insert(&txn, *pos, ins).unwrap();
|
|
}
|
|
|
|
if i % 10 == 0 {
|
|
loro.import(loro_b.export(loro.vv_cloned()));
|
|
loro_b.import(loro.export(loro_b.vv_cloned()));
|
|
}
|
|
}
|
|
loro_b.diagnose();
|
|
loro.diagnose();
|
|
println!("Elapsed {}ms", start.elapsed().as_millis());
|
|
loro_c.import(loro.export(loro_c.vv_cloned()));
|
|
println!("Elapsed {}ms", start.elapsed().as_millis());
|
|
}
|