Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a few somewhat redundant benchmarks #108

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions benches/single_thread_single_byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
//! This is *not* a typical use case but it should nevertheless be useful
//! for comparing the overhead of different methods.

use std::io::{Read, Write};
use std::mem::MaybeUninit;

use criterion::{black_box, criterion_group, criterion_main};
use criterion::{AxisScale, PlotConfiguration};

Expand Down Expand Up @@ -43,57 +40,6 @@ pub fn criterion_benchmark(criterion: &mut criterion::Criterion) {
c.pop().unwrap()
});

add_function(&mut group, "2-slice-read", |i| {
p.push(i).unwrap();
let chunk = c.read_chunk(1).unwrap();
let (s, _) = chunk.as_slices();
let result = s[0];
chunk.commit_all();
result
});

add_function(&mut group, "2-slice-write", |i| {
let mut chunk = p.write_chunk(1).unwrap();
let (s, _) = chunk.as_mut_slices();
s[0] = i;
chunk.commit_all();
c.pop().unwrap()
});

add_function(&mut group, "2-slice-write-uninit", |i| {
let mut chunk = p.write_chunk_uninit(1).unwrap();
let (s, _) = chunk.as_mut_slices();
s[0] = MaybeUninit::new(i);
unsafe {
chunk.commit_all();
}
c.pop().unwrap()
});

add_function(&mut group, "3-iterate-read", |i| {
p.push(i).unwrap();
let chunk = c.read_chunk(1).unwrap();
chunk.into_iter().next().unwrap()
});

add_function(&mut group, "3-iterate-write", |i| {
let chunk = p.write_chunk_uninit(1).unwrap();
chunk.fill_from_iter(&mut std::iter::once(i));
c.pop().unwrap()
});

let mut buf = [0];
add_function(&mut group, "4-read", |i| {
p.push(i).unwrap();
let _ = c.read(&mut buf).unwrap();
buf[0]
});

add_function(&mut group, "4-write", |i| {
let _ = p.write(&[i]).unwrap();
c.pop().unwrap()
});

group.finish();
}

Expand Down
18 changes: 0 additions & 18 deletions benches/single_thread_with_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ pub fn criterion_benchmark(criterion: &mut criterion::Criterion) {

let (mut p, mut c) = RingBuffer::<u8>::new(CHUNK_SIZE + 1);

add_function(&mut group, "1-pop", |data| {
let mut result = [0; CHUNK_SIZE];
let _ = p.write(data).unwrap();
for i in result.iter_mut() {
*i = c.pop().unwrap();
}
result
});

add_function(&mut group, "1-push", |data| {
let mut result = [0; CHUNK_SIZE];
for &i in data.iter() {
p.push(i).unwrap();
}
let _ = c.read(&mut result).unwrap();
result
});

add_function(&mut group, "2-slice-read", |data| {
let mut result = [0; CHUNK_SIZE];
let _ = p.write(data).unwrap();
Expand Down