From c38dd1040cf1e472df82afe3dd86f03cd232b13d Mon Sep 17 00:00:00 2001 From: Petr Tsymbarovich Date: Mon, 24 Aug 2026 15:15:54 +0300 Subject: [PATCH] fix(benches): slow npy reading in Rust --- benches/ptfkit-rs/src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/benches/ptfkit-rs/src/main.rs b/benches/ptfkit-rs/src/main.rs index e1ab19f..2ed57cf 100644 --- a/benches/ptfkit-rs/src/main.rs +++ b/benches/ptfkit-rs/src/main.rs @@ -1,6 +1,7 @@ use std::error::Error; use std::fs::File; use std::hint::black_box; +use std::io::BufReader; use std::path::Path; use std::time::Instant; @@ -24,7 +25,8 @@ fn parse_arguments() -> Result> { fn load_array(dataset: &Path, name: &str) -> Result, Box> { let file = File::open(dataset.join(format!("{name}.npy")))?; - Ok(npyz::NpyFile::new(file)?.into_vec::()?) + let reader = BufReader::new(file); + Ok(npyz::NpyFile::new(reader)?.into_vec::()?) } fn print_record(case: &str, samples: usize, elapsed_ns: u128) {