added file backups

This commit is contained in:
2024-06-03 09:54:40 +02:00
parent 2ea8ba5a39
commit 709ffb313f

View File

@@ -27,10 +27,10 @@ fn main() {
let bounds: Bounds = Bounds::new(LinearBounds::new(3.1_f64, 3.2_f64), LinearBounds::new(-15_f64, 35_f64)); let bounds: Bounds = Bounds::new(LinearBounds::new(3.1_f64, 3.2_f64), LinearBounds::new(-15_f64, 35_f64));
let func: Function = Function::new(f); let func: Function = Function::new(f);
let start: Instant = Instant::now(); //let start: Instant = Instant::now();
println!("{}\n{}ms", func.approximate(&bounds, 10_000_000, THREAD_CNT), start.elapsed().as_millis()) //println!("{}\n{}ms", func.approximate(&bounds, 10_000_000, THREAD_CNT), start.elapsed().as_millis())
//simulate(&bounds, &func) simulate(&bounds, &func)
} }
fn simulate(bounds: &Bounds, func: &Function) { fn simulate(bounds: &Bounds, func: &Function) {
@@ -48,12 +48,12 @@ fn simulate(bounds: &Bounds, func: &Function) {
println!(); println!();
} }
sample_cnt *= 10; sample_cnt *= 10;
}
let file: io::Result<File> = File::create("output.json"); let file: io::Result<File> = File::create(format!("output{}.json", sample_cnt.ilog10()));
if file.is_err() { if file.is_err() {
panic!("Error creating output file") panic!("Error creating output file")
} }
if let Err(_) = file.unwrap().write(result.to_json().to_string().as_bytes()) { panic!("Error writing to file") }; if let Err(_) = file.unwrap().write(result.to_json().to_string().as_bytes()) { panic!("Error writing to file") };
} }
}