From c42cc478febdeee2135238a159fb4dcd26563d5d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 14 Mar 2026 14:34:07 +0100 Subject: [PATCH] performance-metrics: Add micro benchmark support Introduce support for in process micro benchmarks alongside the existing VM level performance tests. Micro benchmarks are integrated into the same PerformanceTest/TEST_LIST infrastructure and follow the same iteration, timeout, and reporting pipeline. They are distinguished by a micro_* name prefix. The test dispatch loop is refactored to pre filter the test list and gate init/cleanup behind a flag, so that pure micro benchmark runs skip the expensive VM lifecycle entirely. Mixed runs (VM + micro) continue to work correctly. Signed-off-by: Anatol Belski --- performance-metrics/src/main.rs | 37 +++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index bef0b74ab..d1228153d 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -1338,24 +1338,35 @@ fn main() { .unwrap_or_default(), }); - init_tests(&overrides); + // Determine which tests will actually run. + let tests_to_run: Vec<&&PerformanceTest> = test_list + .iter() + .filter(|t| test_filter.is_empty() || test_filter.iter().any(|&s| t.name.contains(s))) + .collect(); - for test in test_list.iter() { - if test_filter.is_empty() || test_filter.iter().any(|&s| test.name.contains(s)) { - settle_host(); - match run_test_with_timeout(test, &overrides) { - Ok(r) => { - metrics_report.results.push(r); - } - Err(e) => { - eprintln!("Aborting test due to error: '{e:?}'"); - std::process::exit(1); - } + // Skip heavy VM level init/cleanup when only micro benchmarks are selected. + let needs_vm_tests = tests_to_run.iter().any(|t| !t.name.starts_with("micro_")); + + if needs_vm_tests { + init_tests(&overrides); + } + + for test in tests_to_run { + settle_host(); + match run_test_with_timeout(test, &overrides) { + Ok(r) => { + metrics_report.results.push(r); + } + Err(e) => { + eprintln!("Aborting test due to error: '{e:?}'"); + std::process::exit(1); } } } - cleanup_tests(); + if needs_vm_tests { + cleanup_tests(); + } let mut report_file: Box = if let Some(file) = cmd_arguments.get_one::("report-file") {