From 275295d05fe359f82cf9bf393a247d253ef0098f Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sun, 3 Dec 2023 21:39:29 +0100 Subject: [PATCH] Remove a few somewhat redundant benchmarks --- benches/single_thread_single_byte.rs | 54 ---------------------------- benches/single_thread_with_chunks.rs | 18 ---------- 2 files changed, 72 deletions(-) diff --git a/benches/single_thread_single_byte.rs b/benches/single_thread_single_byte.rs index fe1ac83..d771c47 100644 --- a/benches/single_thread_single_byte.rs +++ b/benches/single_thread_single_byte.rs @@ -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}; @@ -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(); } diff --git a/benches/single_thread_with_chunks.rs b/benches/single_thread_with_chunks.rs index 93f8b18..9c73945 100644 --- a/benches/single_thread_with_chunks.rs +++ b/benches/single_thread_with_chunks.rs @@ -36,24 +36,6 @@ pub fn criterion_benchmark(criterion: &mut criterion::Criterion) { let (mut p, mut c) = RingBuffer::::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();