Skip to content

Commit

Permalink
Remove a few somewhat redundant benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Dec 3, 2023
1 parent 73729ef commit 275295d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
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

0 comments on commit 275295d

Please sign in to comment.