Skip to content

Commit

Permalink
fix: move BenchmarkFormat to the library
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Dec 20, 2024
1 parent 9b9403c commit c1829a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
use std::path::PathBuf;

use benchmark_format::BenchmarkFormat;
use clap::Parser;

pub mod benchmark_format;

///
/// The compiler tester arguments.
///
Expand Down Expand Up @@ -44,8 +41,8 @@ pub struct Arguments {
pub benchmark: Option<PathBuf>,

/// 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)]
Expand Down
9 changes: 4 additions & 5 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)?
}
}
Expand All @@ -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() {
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions compiler_tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c1829a9

Please sign in to comment.