chore: cargo style fix

This commit is contained in:
Zixuan Chen 2022-10-28 18:28:55 +08:00
parent c56c286d76
commit 3c03538e0e
6 changed files with 32 additions and 25 deletions

View file

@ -1,23 +1,31 @@
use arbitrary::Unstructured;
use criterion::{criterion_group, criterion_main, Criterion};
use loro_core::fuzz::test_multi_sites;
use loro_core::fuzz::Action;
use rand::Rng;
use rand::SeedableRng;
#[cfg(feature = "fuzzing")]
mod run {
use super::*;
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) {
let mut rgn = rand::rngs::StdRng::seed_from_u64(0);
let mut bytes = Vec::new();
for _ in 0..1000 {
bytes.push(rgn.gen::<u8>());
pub fn criterion_benchmark(c: &mut Criterion) {
let mut rgn = rand::rngs::StdRng::seed_from_u64(0);
let mut bytes = Vec::new();
for _ in 0..1000 {
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);

View file

@ -1,3 +1,4 @@
#![allow(unused)]
use std::{
cell::{Ref, RefCell, RefMut},
rc::{Rc, Weak as RcWeak},

View file

@ -4,7 +4,6 @@
mod iter;
use std::{
marker::PhantomPinned,
sync::{Arc, RwLock, Weak},
};
use fxhash::{FxHashMap, FxHashSet};

View file

@ -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;
@ -7,8 +7,7 @@ use crate::{
rle_trait::{GlobalIndex, HasIndex, ZeroElement},
rle_tree::{
node::{InternalNode, LeafNode},
tree_trait::GlobalTreeTrait,
Position, UnsafeCursor,
tree_trait::GlobalTreeTrait, UnsafeCursor,
},
HasLength, Mergable, Rle, RleTree, Sliceable,
};

View file

@ -3,7 +3,7 @@ use std::{
fmt::{Debug, Error, Formatter},
};
use fxhash::{FxBuildHasher, FxHashSet, FxHasher};
use fxhash::{FxBuildHasher, FxHashSet};
use smallvec::SmallVec;
use crate::rle_tree::{

View file

@ -20,8 +20,8 @@ check:
check-unsafe:
env RUSTFLAGS="-Funsafe-code --cap-lints=warn" cargo check
fix:
cargo clippy --fix
fix *FLAGS:
cargo clippy --fix {{FLAGS}}
deny:
cargo deny check