From 18a27233cdcb4083a7d8e01b5831e0b202ee98ff Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Mon, 20 Oct 2025 10:31:49 +0300 Subject: [PATCH] make report more benchmarks friendly --- crates/core/src/helpers/test.rs | 4 +-- crates/report/src/aggregator.rs | 45 ++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/crates/core/src/helpers/test.rs b/crates/core/src/helpers/test.rs index 6c39f74..ff30b86 100644 --- a/crates/core/src/helpers/test.rs +++ b/crates/core/src/helpers/test.rs @@ -312,8 +312,8 @@ impl<'a> TestDefinition<'a> { let test_case_status = report .execution_information .get(&(self.metadata_file_path.to_path_buf().into())) - .and_then(|obj| obj.get(&self.case_idx)) - .and_then(|obj| obj.get(&self.mode)) + .and_then(|obj| obj.case_reports.get(&self.case_idx)) + .and_then(|obj| obj.mode_execution_reports.get(&self.mode)) .and_then(|obj| obj.status.as_ref()); match test_case_status { diff --git a/crates/report/src/aggregator.rs b/crates/report/src/aggregator.rs index 2c0af55..a17669f 100644 --- a/crates/report/src/aggregator.rs +++ b/crates/report/src/aggregator.rs @@ -237,9 +237,11 @@ impl ReportAggregator { .execution_information .entry(specifier.metadata_file_path.clone().into()) .or_default() + .case_reports .iter() .flat_map(|(case_idx, mode_to_execution_map)| { let case_status = mode_to_execution_map + .mode_execution_reports .get(&specifier.solc_mode)? .status .clone() @@ -390,13 +392,15 @@ impl ReportAggregator { self.runner_rx.close(); } - fn test_case_report(&mut self, specifier: &TestSpecifier) -> &mut TestCaseReport { + fn test_case_report(&mut self, specifier: &TestSpecifier) -> &mut ExecutionReport { self.report .execution_information .entry(specifier.metadata_file_path.clone().into()) .or_default() + .case_reports .entry(specifier.case_idx) .or_default() + .mode_execution_reports .entry(specifier.solc_mode.clone()) .or_default() } @@ -425,11 +429,10 @@ pub struct Report { /// The list of metadata files that were found by the tool. pub metadata_files: BTreeSet, /// Metrics from the execution. + #[serde(skip_serializing_if = "Option::is_none")] pub metrics: Option, /// Information relating to each test case. - #[serde_as(as = "BTreeMap<_, BTreeMap>>")] - pub execution_information: - BTreeMap>>, + pub execution_information: BTreeMap, } impl Report { @@ -445,12 +448,35 @@ impl Report { } #[derive(Clone, Debug, Serialize, Deserialize, Default)] -pub struct TestCaseReport { +pub struct MetadataFileReport { + /// Metrics from the execution. + #[serde(skip_serializing_if = "Option::is_none")] + pub metrics: Option, + /// The report of each case keyed by the case idx. + pub case_reports: BTreeMap, +} + +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct CaseReport { + /// Metrics from the execution. + #[serde(skip_serializing_if = "Option::is_none")] + pub metrics: Option, + /// The [`ExecutionReport`] for each one of the [`Mode`]s. + #[serde_as(as = "HashMap")] + pub mode_execution_reports: HashMap, +} + +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct ExecutionReport { /// Information on the status of the test case and whether it succeeded, failed, or was ignored. #[serde(skip_serializing_if = "Option::is_none")] pub status: Option, + /// Metrics from the execution. + #[serde(skip_serializing_if = "Option::is_none")] + pub metrics: Option, /// Information related to the execution on one of the platforms. - pub platform_execution: BTreeMap>, + pub platform_execution: PlatformKeyedInformation>, } /// Information related to the status of the test. Could be that the test succeeded, failed, or that @@ -557,17 +583,24 @@ pub struct Metrics { pub gas_consumption: Metric, /* Block Fullness */ pub gas_block_fullness: Metric, + #[serde(skip_serializing_if = "Option::is_none")] pub ref_time_block_fullness: Option>, + #[serde(skip_serializing_if = "Option::is_none")] pub proof_size_block_fullness: Option>, } /// The data that we store for a given metric (e.g., TPS). #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Metric { + #[serde(skip_serializing_if = "Option::is_none")] pub minimum: Option>, + #[serde(skip_serializing_if = "Option::is_none")] pub maximum: Option>, + #[serde(skip_serializing_if = "Option::is_none")] pub mean: Option>, + #[serde(skip_serializing_if = "Option::is_none")] pub median: Option>, + #[serde(skip_serializing_if = "Option::is_none")] pub sum: Option>, }