From 054403ae0dd9bb8c856e0cfb15aefe267da33d07 Mon Sep 17 00:00:00 2001 From: David Venhoff Date: Fri, 12 Sep 2025 13:27:08 +0200 Subject: [PATCH] Also write the total cyc time --- src/benchmark_nyx_pt.rs | 3 ++- src/main.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/benchmark_nyx_pt.rs b/src/benchmark_nyx_pt.rs index edbbf3c..a3803ce 100644 --- a/src/benchmark_nyx_pt.rs +++ b/src/benchmark_nyx_pt.rs @@ -29,11 +29,12 @@ impl Benchmark for BenchmarkNyx { } impl ToCsv for AnalyzeData { - const HEADERS: &'static [&'static str] = &["time_main", "time_tsc", "time_qemu"]; + const HEADERS: &'static [&'static str] = &["time_main_cyc", "time_total_cyc", "time_total_tsc", "time_total_qemu"]; fn write(&self, writer: &mut Writer) -> csv::Result<()> { writer.write_record([ self.time_main.as_secs_f64().to_string(), + self.time_cyc.as_secs_f64().to_string(), self.time_tsc.as_secs_f64().to_string(), self.time_qemu.as_secs_f64().to_string(), ]) diff --git a/src/main.rs b/src/main.rs index a6154e9..d80d0cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use crate::benchmark::{Benchmark, ToCsv}; use crate::benchmark_baseline::Baseline; use crate::benchmark_nyx_no_pt::BenchmarkNyxNoPt; use crate::benchmark_nyx_pt::BenchmarkNyx; +use anyhow::Context; use clap::Parser; use std::fmt::Debug; use std::fs; @@ -58,7 +59,7 @@ fn benchmark( ) -> anyhow::Result<()> { warmup(&mut benchmark); let results = benchmark_loop(&mut benchmark); - write_results::(binary_name, output_dir, &results)?; + write_results::(binary_name, output_dir, &results).with_context(|| "Writing results")?; Ok(()) } @@ -89,9 +90,11 @@ fn write_results( output_dir: &Path, results: &[B::BenchmarkResult], ) -> anyhow::Result<()> { - fs::create_dir_all(output_dir)?; + fs::create_dir_all(output_dir) + .with_context(|| format!("Creating output directory {output_dir:?}"))?; let filename = format!("benchmark_{binary_name}_{}", B::TITLE); - let file = fs::File::create(output_dir.join(filename))?; + let file = + fs::File::create(output_dir.join(filename)).with_context(|| "Creating output file")?; let mut writer = csv::WriterBuilder::new().from_writer(file); writer.write_record(B::BenchmarkResult::HEADERS)?; for result in results {