diff --git a/src/hyperfine/export/mod.rs b/src/hyperfine/export/mod.rs index 73bc5b4..6e8bdd4 100644 --- a/src/hyperfine/export/mod.rs +++ b/src/hyperfine/export/mod.rs @@ -69,7 +69,7 @@ impl ExportManager { } /// Write the given results to all Exporters contained within this manager - pub fn write_results(&self, results: Vec, unit: Option) -> Result<()> { + pub fn write_results(&self, results: &[BenchmarkResult], unit: Option) -> Result<()> { for e in &self.exporters { let file_content = e.exporter.serialize(&results, unit)?; write_to_file(&e.filename, &file_content)?; diff --git a/src/main.rs b/src/main.rs index 9ec5a60..72d8def 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,6 +49,15 @@ fn run( // Run the benchmarks for (num, cmd) in commands.iter().enumerate() { timing_results.push(run_benchmark(num, cmd, shell_spawning_time, options)?); + + // Export (intermediate) results + let ans = export_manager.write_results(&timing_results, options.time_unit); + if let Err(e) = ans { + error(&format!( + "The following error occurred while exporting: {}", + e + )); + } } // Print relative speed comparison @@ -56,15 +65,6 @@ fn run( write_benchmark_comparison(&timing_results); } - // Export results - let ans = export_manager.write_results(timing_results, options.time_unit); - if let Err(e) = ans { - error(&format!( - "The following error occurred while exporting: {}", - e - )); - } - Ok(()) }