New parameter module

This commit is contained in:
David Peter authored and David Peter committed 2022-02-06 20:19:50 +01:00
1 parent 865290a144
commit 47091a5740
7 files changed
+43 -40

No files matched your search

+4 -3
View File
@@ -1,12 +1,13 @@
use std::collections::BTreeMap;
use std::fmt;
use crate::{error::OptionsError, parameter_range::get_parameterized_commands};
use crate::error::OptionsError;
use crate::parameter::range::get_parameterized_commands;
use clap::ArgMatches;
use crate::tokenize::tokenize;
use crate::types::ParameterValue;
use crate::parameter::tokenize::tokenize;
use crate::parameter::ParameterValue;
use anyhow::{bail, Result};
+1 -2
View File
@@ -1,5 +1,4 @@
use std::num;
use std::num::ParseIntError;
use std::num::{self, ParseIntError};
use rust_decimal::Error as DecimalError;
use thiserror::Error;
+17 -19
View File
@@ -1,24 +1,5 @@
use std::env;
use colored::*;
pub mod app;
pub mod benchmark;
pub mod command;
pub mod error;
pub mod export;
pub mod min_max;
pub mod options;
pub mod outlier_detection;
pub mod output;
pub mod parameter_range;
pub mod relative_speed;
pub mod shell;
pub mod timer;
pub mod tokenize;
pub mod types;
pub mod units;
use app::get_arg_matches;
use benchmark::result::BenchmarkResult;
use benchmark::{mean_shell_spawning_time, run_benchmark};
@@ -27,6 +8,23 @@ use export::ExportManager;
use options::{Options, OutputStyleOption};
use anyhow::{bail, Result};
use colored::*;
pub mod app;
pub mod benchmark;
pub mod command;
pub mod error;
pub mod export;
pub mod min_max;
pub mod numeric;
pub mod options;
pub mod outlier_detection;
pub mod output;
pub mod parameter;
pub mod relative_speed;
pub mod shell;
pub mod timer;
pub mod units;
pub fn write_benchmark_comparison(results: &[BenchmarkResult]) {
if results.len() < 2 {
-15
View File
@@ -46,18 +46,3 @@ impl TryFrom<NumericType> for usize {
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParameterValue {
Text(String),
Numeric(NumericType),
}
impl<'a> ToString for ParameterValue {
fn to_string(&self) -> String {
match self {
ParameterValue::Text(ref value) => value.clone(),
ParameterValue::Numeric(value) => value.to_string(),
}
}
}
+19
View File
@@ -0,0 +1,19 @@
use crate::numeric::NumericType;
pub mod range;
pub mod tokenize;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParameterValue {
Text(String),
Numeric(NumericType),
}
impl<'a> ToString for ParameterValue {
fn to_string(&self) -> String {
match self {
ParameterValue::Text(ref value) => value.clone(),
ParameterValue::Numeric(value) => value.to_string(),
}
}
}
@@ -5,9 +5,10 @@ use std::str::FromStr;
use clap::Values;
use rust_decimal::Decimal;
use super::ParameterValue;
use crate::command::Command;
use crate::error::ParameterScanError;
use crate::types::{NumericType, ParameterValue};
use crate::numeric::NumericType;
trait Numeric:
Add<Output = Self>
File renamed without changes.