mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 12:57:20 +00:00
chore: cargo style fix
This commit is contained in:
parent
c56c286d76
commit
3c03538e0e
6 changed files with 32 additions and 25 deletions
|
@ -1,23 +1,31 @@
|
||||||
use arbitrary::Unstructured;
|
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use loro_core::fuzz::test_multi_sites;
|
#[cfg(feature = "fuzzing")]
|
||||||
use loro_core::fuzz::Action;
|
mod run {
|
||||||
use rand::Rng;
|
use super::*;
|
||||||
use rand::SeedableRng;
|
use arbitrary::Unstructured;
|
||||||
|
use loro_core::fuzz::test_multi_sites;
|
||||||
|
use loro_core::fuzz::Action;
|
||||||
|
use rand::Rng;
|
||||||
|
use rand::SeedableRng;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
let mut rgn = rand::rngs::StdRng::seed_from_u64(0);
|
let mut rgn = rand::rngs::StdRng::seed_from_u64(0);
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
bytes.push(rgn.gen::<u8>());
|
bytes.push(rgn.gen::<u8>());
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut gen = Unstructured::new(&bytes);
|
||||||
|
let actions = gen.arbitrary::<[Action; 200]>().unwrap();
|
||||||
|
c.bench_function("random text edit 2 sites", |b| {
|
||||||
|
b.iter(|| test_multi_sites(2, actions.clone().into()))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut gen = Unstructured::new(&bytes);
|
|
||||||
let actions = gen.arbitrary::<[Action; 200]>().unwrap();
|
|
||||||
c.bench_function("random text edit 2 sites", |b| {
|
|
||||||
b.iter(|| test_multi_sites(2, actions.clone().into()))
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
pub fn dumb(_c: &mut Criterion) {}
|
||||||
|
|
||||||
criterion_group!(benches, criterion_benchmark);
|
#[cfg(feature = "fuzzing")]
|
||||||
|
criterion_group!(benches, run::criterion_benchmark);
|
||||||
|
#[cfg(not(feature = "fuzzing"))]
|
||||||
|
criterion_group!(benches, dumb);
|
||||||
criterion_main!(benches);
|
criterion_main!(benches);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(unused)]
|
||||||
use std::{
|
use std::{
|
||||||
cell::{Ref, RefCell, RefMut},
|
cell::{Ref, RefCell, RefMut},
|
||||||
rc::{Rc, Weak as RcWeak},
|
rc::{Rc, Weak as RcWeak},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
mod iter;
|
mod iter;
|
||||||
use std::{
|
use std::{
|
||||||
marker::PhantomPinned,
|
marker::PhantomPinned,
|
||||||
sync::{Arc, RwLock, Weak},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use fxhash::{FxHashMap, FxHashSet};
|
use fxhash::{FxHashMap, FxHashSet};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use bumpalo::boxed::Box as BumpBox;
|
|
||||||
use std::{cell::UnsafeCell, fmt::Debug, ptr::NonNull};
|
use std::{fmt::Debug, ptr::NonNull};
|
||||||
|
|
||||||
use fxhash::FxHashSet;
|
use fxhash::FxHashSet;
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ use crate::{
|
||||||
rle_trait::{GlobalIndex, HasIndex, ZeroElement},
|
rle_trait::{GlobalIndex, HasIndex, ZeroElement},
|
||||||
rle_tree::{
|
rle_tree::{
|
||||||
node::{InternalNode, LeafNode},
|
node::{InternalNode, LeafNode},
|
||||||
tree_trait::GlobalTreeTrait,
|
tree_trait::GlobalTreeTrait, UnsafeCursor,
|
||||||
Position, UnsafeCursor,
|
|
||||||
},
|
},
|
||||||
HasLength, Mergable, Rle, RleTree, Sliceable,
|
HasLength, Mergable, Rle, RleTree, Sliceable,
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
||||||
fmt::{Debug, Error, Formatter},
|
fmt::{Debug, Error, Formatter},
|
||||||
};
|
};
|
||||||
|
|
||||||
use fxhash::{FxBuildHasher, FxHashSet, FxHasher};
|
use fxhash::{FxBuildHasher, FxHashSet};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use crate::rle_tree::{
|
use crate::rle_tree::{
|
||||||
|
|
4
justfile
4
justfile
|
@ -20,8 +20,8 @@ check:
|
||||||
check-unsafe:
|
check-unsafe:
|
||||||
env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check
|
env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check
|
||||||
|
|
||||||
fix:
|
fix *FLAGS:
|
||||||
cargo clippy --fix
|
cargo clippy --fix {{FLAGS}}
|
||||||
|
|
||||||
deny:
|
deny:
|
||||||
cargo deny check
|
cargo deny check
|
||||||
|
|
Loading…
Reference in a new issue