Debian Codegraph @

src/benchmarks/iter.rs

raw symbols SCIP
1 use craterust-analyzer cargo ringbuf 0.3.3 crate/::HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#;
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/iter/RB_SIZE.: usize = 1024;
6
7 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
8 fn push_iter_x1000rust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/push_iter_x1000().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
9 let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/RB_SIZE.);
10 let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
11
12 prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[0; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/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 cons.skiprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]skip().(RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/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);
14
15 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| {
16 prod.push_iterrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_iter().(&mut (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1000).into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/impl#[I][IntoIterator]into_iter().());
17 black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(cons.as_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_slices().());
18 unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(1000) };
19 });
20 }
21
22 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
23 fn pop_iter_x1000rust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/pop_iter_x1000().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
24 let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/RB_SIZE.);
25 let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().();
26
27 prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[0; RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/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]);
28 cons.skiprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]skip().(RB_SIZErust-analyzer cargo ringbuf 0.3.3 benchmarks/iter/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);
29 prod.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(&[1; 1000]);
30
31 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| {
32 for x in cons.pop_iterrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_iter().() {
33 black_boxrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/black_box().(x);
34 }
35 unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(1000) };
36 });
37 }