mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 00:28:33 +00:00
#### PR Dependency Tree * **PR #14243** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Batch management API for coordinated document mutations and change tracking. * New document accessors (IDs, state snapshots, change/delete set queries) and subscriber count. * **Chores** * Upgraded Rust edition across packages to 2024. * Repository-wide formatting, stylistic cleanups and test adjustments. * **Breaking Changes** * Removed the Node native bindings package and its JS/TS declarations and tests (no longer published/available). <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
80 lines
1.9 KiB
Rust
80 lines
1.9 KiB
Rust
use std::time::Duration;
|
|
|
|
use criterion::{Criterion, criterion_group, criterion_main};
|
|
|
|
fn operations(c: &mut Criterion) {
|
|
let mut group = c.benchmark_group("ops/map");
|
|
group.measurement_time(Duration::from_secs(15));
|
|
|
|
group.bench_function("yrs/insert", |b| {
|
|
let base_text = "test1 test2 test3 test4 test5 test6 test7 test8 test9"
|
|
.split(' ')
|
|
.collect::<Vec<_>>();
|
|
|
|
b.iter(|| {
|
|
use yrs::{Doc, Map, Transact};
|
|
let doc = Doc::new();
|
|
let map = doc.get_or_insert_map("test");
|
|
|
|
let mut trx = doc.transact_mut();
|
|
for (idx, key) in base_text.iter().enumerate() {
|
|
map.insert(&mut trx, key.to_string(), idx as f64);
|
|
}
|
|
|
|
drop(trx);
|
|
});
|
|
});
|
|
|
|
group.bench_function("yrs/get", |b| {
|
|
use yrs::{Doc, Map, Transact};
|
|
|
|
let base_text = "test1 test2 test3 test4 test5 test6 test7 test8 test9"
|
|
.split(' ')
|
|
.collect::<Vec<_>>();
|
|
|
|
let doc = Doc::new();
|
|
let map = doc.get_or_insert_map("test");
|
|
|
|
let mut trx = doc.transact_mut();
|
|
for (idx, key) in base_text.iter().enumerate() {
|
|
map.insert(&mut trx, key.to_string(), idx as f64);
|
|
}
|
|
drop(trx);
|
|
|
|
b.iter(|| {
|
|
let trx = doc.transact();
|
|
for key in &base_text {
|
|
map.get(&trx, key).unwrap();
|
|
}
|
|
});
|
|
});
|
|
|
|
group.bench_function("yrs/remove", |b| {
|
|
let base_text = "test1 test2 test3 test4 test5 test6 test7 test8 test9"
|
|
.split(' ')
|
|
.collect::<Vec<_>>();
|
|
|
|
b.iter(|| {
|
|
use yrs::{Doc, Map, Transact};
|
|
let doc = Doc::new();
|
|
let map = doc.get_or_insert_map("test");
|
|
|
|
let mut trx = doc.transact_mut();
|
|
for (idx, key) in base_text.iter().enumerate() {
|
|
map.insert(&mut trx, key.to_string(), idx as f64);
|
|
}
|
|
|
|
for key in &base_text {
|
|
map.remove(&mut trx, key).unwrap();
|
|
}
|
|
|
|
drop(trx);
|
|
});
|
|
});
|
|
|
|
group.finish();
|
|
}
|
|
|
|
criterion_group!(benches, operations);
|
|
criterion_main!(benches);
|