From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- vendor/lebe/benches/benches.rs | 137 ----------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 vendor/lebe/benches/benches.rs (limited to 'vendor/lebe/benches') diff --git a/vendor/lebe/benches/benches.rs b/vendor/lebe/benches/benches.rs deleted file mode 100644 index eca67f5..0000000 --- a/vendor/lebe/benches/benches.rs +++ /dev/null @@ -1,137 +0,0 @@ -#[macro_use] -extern crate bencher; - -use bencher::Bencher; -use lebe::prelude::*; -use byteorder::{ReadBytesExt, LittleEndian, BigEndian, WriteBytesExt}; -use std::io::{Read, Write, Cursor}; - -const COUNT_8: usize = 2048; -const COUNT_16: usize = COUNT_8 / 2; -const COUNT_32: usize = COUNT_8 / 4; -const COUNT_64: usize = COUNT_8 / 8; - - -fn bytes(count: usize) -> Cursor> { - let vec: Vec = (0..count).map(|i| (i % 256) as u8).collect(); - Cursor::new(vec) -} - -fn floats(count: usize) -> Vec { - (0..count).map(|i| i as f32).collect() -} - -fn read_slice_f32_le_crate(bench: &mut Bencher) { - bench.iter(move ||{ - let mut target = vec![ 0_f32; COUNT_32 ]; - bencher::black_box(bytes(COUNT_8).read_from_little_endian_into(target.as_mut_slice())).unwrap(); - bencher::black_box(target); - }) -} - -fn read_slice_f32_le_byteorder(bench: &mut Bencher) { - bench.iter(move ||{ - let mut target = vec![ 0_f32; COUNT_32 ]; - bencher::black_box(bytes(COUNT_8).read_f32_into::(target.as_mut_slice())).unwrap(); - bencher::black_box(target); - }) -} - -fn read_slice_f32_be_crate(bench: &mut Bencher) { - bench.iter(move ||{ - let mut target = vec![ 0_f32; COUNT_32 ]; - bencher::black_box(bytes(COUNT_8).read_from_big_endian_into(target.as_mut_slice())).unwrap(); - bencher::black_box(target); - }) -} - -fn read_slice_f32_be_byteorder(bench: &mut Bencher) { - bench.iter(move ||{ - let mut target = vec![ 0_f32; COUNT_32 ]; - bencher::black_box(bytes(COUNT_8).read_f32_into::(target.as_mut_slice())).unwrap(); - bencher::black_box(target); - }) -} - -// FIXME faster than baseline?!?!! -fn write_slice_f32_le_crate(bench: &mut Bencher) { - bench.iter(move ||{ - let data = floats(COUNT_32); - let mut output = Vec::with_capacity(COUNT_8); - - bencher::black_box(output.write_as_little_endian(data.as_slice())).unwrap(); - assert_eq!(output.len(), COUNT_8); - bencher::black_box(output); - }) -} - -fn write_slice_f32_le_byteorder(bench: &mut Bencher) { - bench.iter(move ||{ - let data = floats(COUNT_32); - let mut output = Vec::with_capacity(COUNT_8); - - for number in data { - bencher::black_box(output.write_f32::(number)).unwrap(); - } - - assert_eq!(output.len(), COUNT_8); - bencher::black_box(output); - }) -} - - -fn write_slice_f32_be_crate(bench: &mut Bencher) { - bench.iter(move ||{ - let data = floats(COUNT_32); - let mut output = Vec::with_capacity(COUNT_8); - - bencher::black_box(output.write_as_big_endian(data.as_slice())).unwrap(); - assert_eq!(output.len(), COUNT_8); - bencher::black_box(output); - }) -} - -fn write_slice_f32_be_byteorder(bench: &mut Bencher) { - bench.iter(move ||{ - let data = floats(COUNT_32); - let mut output = Vec::with_capacity(COUNT_8); - - for number in data { - bencher::black_box(output.write_f32::(number)).unwrap(); - } - - assert_eq!(output.len(), COUNT_8); - bencher::black_box(output); - }) -} - - - -fn read_slice_baseline(bench: &mut Bencher) { - bench.iter(move ||{ - let mut target = vec![ 0_u8; COUNT_8 ]; - bencher::black_box(bytes(COUNT_8).read_exact(target.as_mut_slice())).unwrap(); - bencher::black_box(target); - }) -} - - -fn write_slice_baseline(bench: &mut Bencher) { - bench.iter(move ||{ - let data = bytes(COUNT_8).into_inner(); - let mut output = Vec::with_capacity(COUNT_8); - - bencher::black_box(output.write_all(data.as_slice())).unwrap(); - bencher::black_box(output); - }) -} - -benchmark_group!( - benches, - read_slice_f32_be_byteorder, read_slice_f32_be_crate, read_slice_f32_le_byteorder, - read_slice_f32_le_crate, write_slice_f32_le_byteorder, write_slice_f32_le_crate, - write_slice_f32_be_byteorder, write_slice_f32_be_crate, - read_slice_baseline, write_slice_baseline -); - -benchmark_main!(benches); \ No newline at end of file -- cgit v1.2.3