Update benchmark tests with filtering

This commit is contained in:
Michael Schimmel
2026-02-22 12:07:58 +01:00
parent cb94f20c0b
commit 5a017fb932
9 changed files with 69 additions and 35 deletions
+37 -14
View File
@@ -252,21 +252,34 @@ impl CompilerApp {
self.output_log = log;
}
fn run_benchmarks(&mut self, update: bool) {
fn run_benchmarks(&mut self, update: bool, only_current: bool) {
use myc::utils::tester;
let filter = if only_current {
self.current_example_path
.as_ref()
.and_then(|p| p.file_name())
.map(|n| n.to_string_lossy().to_string())
} else {
None
};
if cfg!(debug_assertions) && !update {
self.output_log = String::from(
"⚠️ WARNING: Benchmarks in Debug mode are inaccurate!\nUse Release build for real measurements.\n\n",
);
} else {
self.output_log = String::from(if update {
"UPDATING BASELINES...\n\n"
} else {
"RUNNING BENCHMARKS...\n\n"
});
self.output_log = format!(
"{}...\n\n",
match (update, only_current) {
(true, true) => "UPDATING BASELINE FOR CURRENT SCRIPT",
(true, false) => "UPDATING ALL BASELINES",
(false, _) => "RUNNING BENCHMARKS",
}
);
}
let results = tester::run_benchmarks(update);
let results = tester::run_benchmarks(update, filter.as_deref());
let mut log = self.output_log.clone();
for res in results {
@@ -331,21 +344,31 @@ impl eframe::App for CompilerApp {
let is_debug = cfg!(debug_assertions);
ui.add_enabled_ui(!is_debug, |ui: &mut egui::Ui| {
let btn = ui.button("Run Benchmarks");
let btn = ui.button("Run All Benchmarks");
if is_debug {
btn.on_hover_text("Benchmarks are only available in Release builds.");
} else if btn.clicked() {
self.run_benchmarks(false);
self.run_benchmarks(false, false);
ui.close();
}
let btn_base = ui.button("Update Baselines");
let btn_base_all = ui.button("Update All Baselines");
if is_debug {
btn_base.on_hover_text(
btn_base_all.on_hover_text(
"Updating baselines is only allowed in Release builds.",
);
} else if btn_base.clicked() {
self.run_benchmarks(true);
} else if btn_base_all.clicked() {
self.run_benchmarks(true, false);
ui.close();
}
let btn_base_curr = ui.button("Update Current Baseline");
if is_debug {
btn_base_curr.on_hover_text(
"Updating baselines is only allowed in Release builds.",
);
} else if btn_base_curr.clicked() {
self.run_benchmarks(true, true);
ui.close();
}
});
@@ -406,7 +429,7 @@ impl eframe::App for CompilerApp {
if is_debug {
bench_btn.on_hover_text("Benchmarks are only available in Release builds.");
} else if bench_btn.clicked() {
self.run_benchmarks(false);
self.run_benchmarks(false, false);
}
});
});