From bf943e3d27069265935f3114364c7ea1ef73aeb6 Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Wed, 17 Apr 2024 22:53:19 +0700 Subject: [PATCH] Improve the error on benchmarking on low optimizer modes --- compiler_tester/src/compiler_tester/main.rs | 2 +- compiler_tester/src/summary/mod.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler_tester/src/compiler_tester/main.rs b/compiler_tester/src/compiler_tester/main.rs index cedd9ae5..5dbd45cd 100644 --- a/compiler_tester/src/compiler_tester/main.rs +++ b/compiler_tester/src/compiler_tester/main.rs @@ -165,7 +165,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { ); if let Some(path) = arguments.benchmark { - let benchmark = summary.benchmark(); + let benchmark = summary.benchmark()?; benchmark.write_to_file(path)?; } diff --git a/compiler_tester/src/summary/mod.rs b/compiler_tester/src/summary/mod.rs index 0c328c56..c12a307e 100644 --- a/compiler_tester/src/summary/mod.rs +++ b/compiler_tester/src/summary/mod.rs @@ -75,7 +75,7 @@ impl Summary { /// /// Returns the benchmark structure. /// - pub fn benchmark(&self) -> benchmark_analyzer::Benchmark { + pub fn benchmark(&self) -> anyhow::Result { let mut benchmark = benchmark_analyzer::Benchmark::default(); benchmark.groups.insert( format!( @@ -132,16 +132,17 @@ impl Summary { .insert(key.clone(), benchmark_element.clone()); } + let group_key = format!("{} {}", benchmark_analyzer::BENCHMARK_ALL_GROUP_NAME, mode); benchmark .groups .get_mut( - format!("{} {}", benchmark_analyzer::BENCHMARK_ALL_GROUP_NAME, mode).as_str(), + group_key.as_str(), ) - .expect("Always exists") + .ok_or_else(|| anyhow::anyhow!("Group `{group_key}` not found. Only M3 and Mz groups are allowed in benchmarking"))? .elements .insert(key, benchmark_element); } - benchmark + Ok(benchmark) } ///