dump state periodically

This commit is contained in:
Daniel Bauer
2018-10-05 21:09:50 +02:00
parent 530ae7b7be
commit 1ec2f3ac45
3 changed files with 36 additions and 45 deletions

View File

@@ -18,6 +18,12 @@ fn get_relative_path(path1: &str, path2: &str) -> String {
path1.parent().unwrap().join(path2).to_str().unwrap().to_string()
}
pub fn vprintln(s: String, verbose: bool) {
if verbose {
println!("{}", s);
}
}
// Read input data into a histogram set by iterating over input files
// given in the metadata file
pub fn read_data(cfg: &Config) -> Option<HistogramSet> {
@@ -43,9 +49,7 @@ pub fn read_data(cfg: &Config) -> Option<HistogramSet> {
match read_window_file(&path, cfg) {
Some(h) => {
histograms.push(h);
if cfg.verbose {
println!("File: {}, {} Data points added.", &path, histograms.last().unwrap().num_points);
}
vprintln(format!("{}, {} data points added.", &path, histograms.last().unwrap().num_points), cfg.verbose);
},
None => {
eprintln!("No data points inside histogram boundaries: {}", &path);