From c1829a92a8fdf5e7f529d788722ffecdd88806fc Mon Sep 17 00:00:00 2001 From: Oleksandr Zarudnyi Date: Sat, 21 Dec 2024 01:45:21 +0800 Subject: [PATCH] fix: move BenchmarkFormat to the library --- .../arguments => }/benchmark_format.rs | 10 +++++++++- .../compiler_tester/{arguments/mod.rs => arguments.rs} | 7 ++----- compiler_tester/src/compiler_tester/main.rs | 9 ++++----- compiler_tester/src/lib.rs | 2 ++ 4 files changed, 17 insertions(+), 11 deletions(-) rename compiler_tester/src/{compiler_tester/arguments => }/benchmark_format.rs (87%) rename compiler_tester/src/compiler_tester/{arguments/mod.rs => arguments.rs} (94%) diff --git a/compiler_tester/src/compiler_tester/arguments/benchmark_format.rs b/compiler_tester/src/benchmark_format.rs similarity index 87% rename from compiler_tester/src/compiler_tester/arguments/benchmark_format.rs rename to compiler_tester/src/benchmark_format.rs index d5e74081..28002bbb 100644 --- a/compiler_tester/src/compiler_tester/arguments/benchmark_format.rs +++ b/compiler_tester/src/benchmark_format.rs @@ -1,8 +1,16 @@ +//! +//! Output format for benchmark data. +//! + +/// /// Output format for benchmark data. -#[derive(Clone, Debug, Default, Eq, PartialEq)] +/// +#[derive(Debug, Default, Clone, PartialEq, Eq)] pub enum BenchmarkFormat { #[default] + /// JSON format. Json, + /// CSV format. Csv, } diff --git a/compiler_tester/src/compiler_tester/arguments/mod.rs b/compiler_tester/src/compiler_tester/arguments.rs similarity index 94% rename from compiler_tester/src/compiler_tester/arguments/mod.rs rename to compiler_tester/src/compiler_tester/arguments.rs index c2335c15..45e912e7 100644 --- a/compiler_tester/src/compiler_tester/arguments/mod.rs +++ b/compiler_tester/src/compiler_tester/arguments.rs @@ -4,11 +4,8 @@ use std::path::PathBuf; -use benchmark_format::BenchmarkFormat; use clap::Parser; -pub mod benchmark_format; - /// /// The compiler tester arguments. /// @@ -44,8 +41,8 @@ pub struct Arguments { pub benchmark: Option, /// The benchmark output format. - #[structopt(long = "benchmark-format", default_value_t = BenchmarkFormat::Json)] - pub benchmark_format: BenchmarkFormat, + #[structopt(long = "benchmark-format", default_value_t = compiler_tester::BenchmarkFormat::Json)] + pub benchmark_format: compiler_tester::BenchmarkFormat, /// Sets the number of threads, which execute the tests concurrently. #[structopt(short, long)] diff --git a/compiler_tester/src/compiler_tester/main.rs b/compiler_tester/src/compiler_tester/main.rs index fa15a793..5735712c 100644 --- a/compiler_tester/src/compiler_tester/main.rs +++ b/compiler_tester/src/compiler_tester/main.rs @@ -8,7 +8,6 @@ use std::path::PathBuf; use std::str::FromStr; use std::time::Instant; -use arguments::benchmark_format::BenchmarkFormat; use clap::Parser; use colored::Colorize; @@ -224,10 +223,10 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { if let Some(path) = arguments.benchmark { let benchmark = summary.benchmark(toolchain)?; match arguments.benchmark_format { - BenchmarkFormat::Json => { + compiler_tester::BenchmarkFormat::Json => { benchmark.write_to_file(path, benchmark_analyzer::JsonSerializer)? } - BenchmarkFormat::Csv => { + compiler_tester::BenchmarkFormat::Csv => { benchmark.write_to_file(path, benchmark_analyzer::CsvSerializer)? } } @@ -244,7 +243,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> { mod tests { use std::path::PathBuf; - use crate::arguments::{benchmark_format::BenchmarkFormat, Arguments}; + use crate::arguments::Arguments; #[test] fn test_manually() { @@ -258,7 +257,7 @@ mod tests { path: vec!["tests/solidity/simple/default.sol".to_owned()], group: vec![], benchmark: None, - benchmark_format: BenchmarkFormat::Json, + benchmark_format: compiler_tester::BenchmarkFormat::Json, threads: Some(1), dump_system: false, disable_deployer: false, diff --git a/compiler_tester/src/lib.rs b/compiler_tester/src/lib.rs index ff5c2a57..c177a3e0 100644 --- a/compiler_tester/src/lib.rs +++ b/compiler_tester/src/lib.rs @@ -7,6 +7,7 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::type_complexity)] +pub(crate) mod benchmark_format; pub(crate) mod compilers; pub(crate) mod directories; pub(crate) mod environment; @@ -26,6 +27,7 @@ use itertools::Itertools; use rayon::iter::IntoParallelIterator; use rayon::iter::ParallelIterator; +pub use crate::benchmark_format::BenchmarkFormat; pub use crate::compilers::eravm::EraVMCompiler; pub use crate::compilers::llvm::LLVMCompiler; pub use crate::compilers::mode::llvm_options::LLVMOptions;