-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve accuracy of columns in CSV reports
- Loading branch information
Showing
12 changed files
with
249 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//! | ||
//! Identifier for the test input. Describes the input type and position but not the actual contents. | ||
//! | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
/// | ||
/// Identifier for the test input. Describes the input type and position but not the actual contents. | ||
/// | ||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] | ||
pub enum Input { | ||
/// The contract deploy, regardless of target. | ||
Deployer { | ||
/// Contract identifier, usually file name and contract name separated by a colon. | ||
contract_identifier: String, | ||
}, | ||
/// The contract call. | ||
Runtime { | ||
/// Index in the array of inputs. | ||
input_index: usize, | ||
/// Input name, provided in the test description. | ||
name: String, | ||
}, | ||
/// The storage empty check. | ||
StorageEmpty { | ||
/// Index in the array of inputs. | ||
input_index: usize, | ||
}, | ||
/// Check account balance. | ||
Balance { | ||
/// Index in the array of inputs. | ||
input_index: usize, | ||
}, | ||
} | ||
|
||
impl std::fmt::Display for Input { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Input::Deployer { | ||
contract_identifier, | ||
} => f.write_fmt(format_args!("#deployer:{contract_identifier}")), | ||
Input::Runtime { input_index, name } => { | ||
f.write_fmt(format_args!("{name}:{input_index}")) | ||
} | ||
Input::StorageEmpty { input_index } => { | ||
f.write_fmt(format_args!("#storage_empty_check:{input_index}")) | ||
} | ||
Input::Balance { input_index } => { | ||
f.write_fmt(format_args!("#balance_check:{input_index}")) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
benchmark_analyzer/src/benchmark/group/element/selector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! | ||
//! Test selector, unambiously locating a test suite, or a specific input. | ||
//! | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::benchmark::group::element::input::Input; | ||
|
||
/// | ||
/// Test selector, unambiously locating a test suite, case, or input. | ||
/// | ||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct Selector { | ||
/// Path to the file containing test. | ||
pub path: String, | ||
/// Name of the case, if any. `None` means nameless case. | ||
pub case: Option<String>, | ||
/// Identifier of the specific input. | ||
pub input: Option<Input>, | ||
} | ||
|
||
impl std::fmt::Display for Selector { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let Self { | ||
path: filename, | ||
case: case_name, | ||
input, | ||
} = self; | ||
f.write_fmt(format_args!("{filename}"))?; | ||
if let Some(case_name) = case_name { | ||
f.write_fmt(format_args!("::{case_name}"))?; | ||
} | ||
if let Some(input) = input { | ||
f.write_fmt(format_args!("[{input}]"))?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! | ||
//! Information associated with the benchmark element. | ||
//! | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::benchmark::group::element::selector::Selector; | ||
|
||
/// | ||
/// Encoded compiler mode. In future, it can be expanded into a structured type | ||
/// shared between crates `benchmark_analyzer` and `compiler_tester`. | ||
/// | ||
pub type Mode = String; | ||
|
||
/// | ||
/// Information associated with the benchmark element. | ||
/// | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct Metadata { | ||
/// Test selector. | ||
pub selector: Selector, | ||
/// Compiler mode. | ||
pub mode: Option<Mode>, | ||
/// Test group | ||
pub group: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! | ||
//! Converts `[InputIdentifier]` to the representation used by the benchmark. | ||
//! | ||
use crate::test::case::input::identifier::InputIdentifier; | ||
|
||
/// | ||
/// Converts `[InputIdentifier]` to the representation used by the benchmark. | ||
/// | ||
pub fn convert_input(input: InputIdentifier) -> benchmark_analyzer::Input { | ||
match input { | ||
InputIdentifier::Deployer { | ||
contract_identifier, | ||
} => benchmark_analyzer::Input::Deployer { | ||
contract_identifier, | ||
}, | ||
InputIdentifier::Runtime { input_index, name } => { | ||
benchmark_analyzer::Input::Runtime { input_index, name } | ||
} | ||
InputIdentifier::StorageEmpty { input_index } => { | ||
benchmark_analyzer::Input::StorageEmpty { input_index } | ||
} | ||
InputIdentifier::Balance { input_index } => { | ||
benchmark_analyzer::Input::Balance { input_index } | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
compiler_tester/src/summary/benchmark_adapters/metadata.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! | ||
//! Converts `[TestDescription]` to the representation used by the benchmark. | ||
//! | ||
use crate::test::description::TestDescription; | ||
|
||
use super::selector::convert_selector; | ||
|
||
/// | ||
/// Converts `[TestSelector]` to the representation used by the benchmark. | ||
/// | ||
pub fn convert_description( | ||
description: &TestDescription, | ||
default_group: &str, | ||
) -> benchmark_analyzer::Metadata { | ||
let TestDescription { | ||
group, | ||
mode, | ||
selector, | ||
} = description.clone(); | ||
let selector = convert_selector(selector); | ||
let mode = mode.map(|m| m.to_string()); | ||
let group = group.unwrap_or(default_group.to_string()); | ||
benchmark_analyzer::Metadata { | ||
selector, | ||
mode, | ||
group, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//! | ||
//! Adapters to convert the test information defined in `compiler_tester` to the | ||
//! representation used by `benchmark_analyzer`. | ||
//! | ||
pub mod input; | ||
pub mod metadata; | ||
pub mod selector; |
16 changes: 16 additions & 0 deletions
16
compiler_tester/src/summary/benchmark_adapters/selector.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//! | ||
//! Converts `[TestSelector]` to the representation used by the benchmark. | ||
//! | ||
use crate::test::selector::TestSelector; | ||
|
||
use super::input::convert_input; | ||
|
||
/// | ||
/// Converts `[TestSelector]` to the representation used by the benchmark. | ||
/// | ||
pub fn convert_selector(selector: TestSelector) -> benchmark_analyzer::TestSelector { | ||
let TestSelector { path, case, input } = selector; | ||
let input = input.map(convert_input); | ||
benchmark_analyzer::TestSelector { path, case, input } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters