diff --git a/.gitignore b/.gitignore index baa1df9..183ce61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target Cargo.lock tests/*.npy +benches/*.npy diff --git a/benches/bench.rs b/benches/bench.rs index 9a46809..001641a 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -38,6 +38,19 @@ macro_rules! gen_benches { }); } + #[bench] + fn read_to_vec(b: &mut Bencher) { + // FIXME: Write to a Cursor> once #16 is merged + let path = concat!("benches/bench_", stringify!($T), ".npy"); + + npy::to_file(path, (0usize..NITER).map($new)).unwrap(); + let bytes = std::fs::read(path).unwrap(); + + b.iter(|| { + bb(npy::NpyData::<$T>::from_bytes(&bytes).unwrap().to_vec()) + }); + } + #[bench] fn write(b: &mut Bencher) { b.iter(|| {