Also write the total cyc time

This commit is contained in:
David Venhoff 2025-09-12 13:27:08 +02:00
parent c2684b995b
commit 054403ae0d
2 changed files with 8 additions and 4 deletions

View File

@ -29,11 +29,12 @@ impl Benchmark for BenchmarkNyx {
} }
impl ToCsv for AnalyzeData { 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<impl Write>) -> csv::Result<()> { fn write(&self, writer: &mut Writer<impl Write>) -> csv::Result<()> {
writer.write_record([ writer.write_record([
self.time_main.as_secs_f64().to_string(), 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_tsc.as_secs_f64().to_string(),
self.time_qemu.as_secs_f64().to_string(), self.time_qemu.as_secs_f64().to_string(),
]) ])

View File

@ -10,6 +10,7 @@ use crate::benchmark::{Benchmark, ToCsv};
use crate::benchmark_baseline::Baseline; use crate::benchmark_baseline::Baseline;
use crate::benchmark_nyx_no_pt::BenchmarkNyxNoPt; use crate::benchmark_nyx_no_pt::BenchmarkNyxNoPt;
use crate::benchmark_nyx_pt::BenchmarkNyx; use crate::benchmark_nyx_pt::BenchmarkNyx;
use anyhow::Context;
use clap::Parser; use clap::Parser;
use std::fmt::Debug; use std::fmt::Debug;
use std::fs; use std::fs;
@ -58,7 +59,7 @@ fn benchmark<B: Benchmark>(
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
warmup(&mut benchmark); warmup(&mut benchmark);
let results = benchmark_loop(&mut benchmark); let results = benchmark_loop(&mut benchmark);
write_results::<B>(binary_name, output_dir, &results)?; write_results::<B>(binary_name, output_dir, &results).with_context(|| "Writing results")?;
Ok(()) Ok(())
} }
@ -89,9 +90,11 @@ fn write_results<B: Benchmark>(
output_dir: &Path, output_dir: &Path,
results: &[B::BenchmarkResult], results: &[B::BenchmarkResult],
) -> anyhow::Result<()> { ) -> 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 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); let mut writer = csv::WriterBuilder::new().from_writer(file);
writer.write_record(B::BenchmarkResult::HEADERS)?; writer.write_record(B::BenchmarkResult::HEADERS)?;
for result in results { for result in results {