better progress report during file read
This commit is contained in:
@@ -5,7 +5,7 @@ use std::time::Instant;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use indicatif::ParallelProgressIterator;
|
||||
use indicatif::{ParallelProgressIterator, ProgressBar};
|
||||
use kiddo::{SquaredEuclidean, immutable::float::kdtree::ImmutableKdTree};
|
||||
use rand::Rng;
|
||||
use rayon::prelude::*;
|
||||
@@ -111,13 +111,19 @@ fn read_data(input_path: &str) -> Result<(Vec<[f64; 2]>, Vec<f64>)> {
|
||||
let mut points = Vec::new();
|
||||
let mut values = Vec::new();
|
||||
|
||||
let pb = ProgressBar::new_spinner();
|
||||
pb.set_message("reading data");
|
||||
pb.enable_steady_tick(std::time::Duration::from_millis(100));
|
||||
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
if let Some((p, v)) = parse_point(&line) {
|
||||
points.push(p);
|
||||
values.push(v);
|
||||
}
|
||||
pb.tick();
|
||||
}
|
||||
pb.finish_with_message("done reading data");
|
||||
|
||||
Ok((points, values))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user