| 1 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::{LocalRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/local/LocalRb#, SharedRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/SharedRb#}; |
| 2 | |
| 3 | use testrust-analyzer cargo test https://github.com/rust-lang/rust/library/test crate/::{black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box()., Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#}; |
| 4 | |
| 5 | const RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE.: usize = 256; |
| 6 | const BATCH_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/BATCH_SIZE.: usize = 100; |
| 7 | |
| 8 | #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:] |
| 9 | fn push_pop_sharedrust-analyzer cargo ringbuf 0.3.3 benchmarks/base/push_pop_shared().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) { |
| 10 | let buf = SharedRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/SharedRb#::<u64, [_; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE.]>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, [MaybeUninit<T>; N]>`][Default]default().(); |
| 11 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 12 | prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[1; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2]); |
| 13 | b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| { |
| 14 | prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 15 | black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 16 | }); |
| 17 | } |
| 18 | |
| 19 | #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:] |
| 20 | fn push_pop_localrust-analyzer cargo ringbuf 0.3.3 benchmarks/base/push_pop_local().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) { |
| 21 | let buf = LocalRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/local/LocalRb#::<u64, [_; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE.]>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`LocalRb<T, [MaybeUninit<T>; N]>`][Default]default().(); |
| 22 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/local/impl#[`LocalRb<T, C>`]split().(); |
| 23 | prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[1; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2]); |
| 24 | b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| { |
| 25 | prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 26 | black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 27 | }); |
| 28 | } |
| 29 | |
| 30 | #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:] |
| 31 | fn push_pop_x100_immediaterust-analyzer cargo ringbuf 0.3.3 benchmarks/base/push_pop_x100_immediate().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) { |
| 32 | let buf = SharedRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/SharedRb#::<u64, [_; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE.]>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, [MaybeUninit<T>; N]>`][Default]default().(); |
| 33 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 34 | prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[1; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2]); |
| 35 | b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| { |
| 36 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#BATCH_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/BATCH_SIZE. { |
| 37 | prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 38 | } |
| 39 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#BATCH_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/BATCH_SIZE. { |
| 40 | black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 41 | } |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:] |
| 46 | fn push_pop_x100_postponedrust-analyzer cargo ringbuf 0.3.3 benchmarks/base/push_pop_x100_postponed().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) { |
| 47 | let buf = SharedRbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/SharedRb#::<u64, [_; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE.]>::defaultrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, [MaybeUninit<T>; N]>`][Default]default().(); |
| 48 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 49 | prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[1; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/RB_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2]); |
| 50 | b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| { |
| 51 | { |
| 52 | let mut prod_cache = prod.postponedrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]postponed().(); |
| 53 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#BATCH_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/BATCH_SIZE. { |
| 54 | prod_cache.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 55 | } |
| 56 | } |
| 57 | { |
| 58 | let mut cons_cache = cons.postponedrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]postponed().(); |
| 59 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#BATCH_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/base/BATCH_SIZE. { |
| 60 | black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(cons_cache.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 61 | } |
| 62 | } |
| 63 | }); |
| 64 | } |