honeycomb_benches/
utils.rs1use std::collections::hash_map::DefaultHasher;
2use std::fs::File;
3use std::hash::Hasher;
4use std::io::Read;
5
6cfg_if::cfg_if! {
7 if #[cfg(feature = "_single_precision")] {
8 pub type FloatType = f32;
12 } else {
13 pub type FloatType = f64;
17 }
18}
19
20pub fn hash_file(path: &str) -> Result<u64, std::io::Error> {
21 let mut file = File::open(path)?;
22 let mut hasher = DefaultHasher::new();
23 let mut buffer = [0; 8192];
24
25 loop {
26 let bytes_read = file.read(&mut buffer)?;
27 if bytes_read == 0 {
28 break;
29 }
30 hasher.write(&buffer[..bytes_read]);
31 }
32
33 Ok(hasher.finish())
34}