mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-03 01:21:25 +00:00
Move more modules around
This commit is contained in:
1 parent
47091a5740
commit
999e7c4566
9 files changed
+59
-59
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod relative_speed;
|
||||||
pub mod result;
|
pub mod result;
|
||||||
|
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use crate::benchmark::result::BenchmarkResult;
|
use super::result::BenchmarkResult;
|
||||||
use crate::units::Scalar;
|
use crate::units::Scalar;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use crate::benchmark::relative_speed::{self, BenchmarkResultWithRelativeSpeed};
|
||||||
use crate::benchmark::result::BenchmarkResult;
|
use crate::benchmark::result::BenchmarkResult;
|
||||||
use crate::output::format::format_duration_value;
|
use crate::output::format::format_duration_value;
|
||||||
use crate::relative_speed::{self, BenchmarkResultWithRelativeSpeed};
|
|
||||||
use crate::units::Unit;
|
use crate::units::Unit;
|
||||||
|
|
||||||
use super::Exporter;
|
use super::Exporter;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::Exporter;
|
use super::Exporter;
|
||||||
|
use crate::benchmark::relative_speed::{self, BenchmarkResultWithRelativeSpeed};
|
||||||
use crate::benchmark::result::BenchmarkResult;
|
use crate::benchmark::result::BenchmarkResult;
|
||||||
use crate::output::format::format_duration_value;
|
use crate::output::format::format_duration_value;
|
||||||
use crate::relative_speed::{self, BenchmarkResultWithRelativeSpeed};
|
|
||||||
use crate::units::Unit;
|
use crate::units::Unit;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
|||||||
+2
-3
@@ -2,7 +2,7 @@ use std::env;
|
|||||||
|
|
||||||
use app::get_arg_matches;
|
use app::get_arg_matches;
|
||||||
use benchmark::result::BenchmarkResult;
|
use benchmark::result::BenchmarkResult;
|
||||||
use benchmark::{mean_shell_spawning_time, run_benchmark};
|
use benchmark::{mean_shell_spawning_time, relative_speed, run_benchmark};
|
||||||
use command::{build_commands, Command};
|
use command::{build_commands, Command};
|
||||||
use export::ExportManager;
|
use export::ExportManager;
|
||||||
use options::{Options, OutputStyleOption};
|
use options::{Options, OutputStyleOption};
|
||||||
@@ -16,12 +16,11 @@ pub mod command;
|
|||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod export;
|
pub mod export;
|
||||||
pub mod min_max;
|
pub mod min_max;
|
||||||
pub mod numeric;
|
pub mod number;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
pub mod outlier_detection;
|
pub mod outlier_detection;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
pub mod parameter;
|
pub mod parameter;
|
||||||
pub mod relative_speed;
|
|
||||||
pub mod shell;
|
pub mod shell;
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
pub mod units;
|
pub mod units;
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
use std::convert::TryFrom;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
use rust_decimal::prelude::ToPrimitive;
|
||||||
|
use rust_decimal::Decimal;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Copy, PartialEq, Eq)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum Number {
|
||||||
|
Int(i32),
|
||||||
|
Decimal(Decimal),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Number {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match *self {
|
||||||
|
Number::Int(i) => fmt::Display::fmt(&i, f),
|
||||||
|
Number::Decimal(i) => fmt::Display::fmt(&i, f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<i32> for Number {
|
||||||
|
fn from(x: i32) -> Number {
|
||||||
|
Number::Int(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Decimal> for Number {
|
||||||
|
fn from(x: Decimal) -> Number {
|
||||||
|
Number::Decimal(x)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<Number> for usize {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn try_from(numeric: Number) -> Result<Self, Self::Error> {
|
||||||
|
match numeric {
|
||||||
|
Number::Int(i) => usize::try_from(i).map_err(|_| ()),
|
||||||
|
Number::Decimal(d) => match d.to_u64() {
|
||||||
|
Some(u) => usize::try_from(u).map_err(|_| ()),
|
||||||
|
None => Err(()),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
use std::convert::TryFrom;
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use rust_decimal::prelude::ToPrimitive;
|
|
||||||
use rust_decimal::Decimal;
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Copy, PartialEq, Eq)]
|
|
||||||
#[serde(untagged)]
|
|
||||||
pub enum NumericType {
|
|
||||||
Int(i32),
|
|
||||||
Decimal(Decimal),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for NumericType {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
match *self {
|
|
||||||
NumericType::Int(i) => fmt::Display::fmt(&i, f),
|
|
||||||
NumericType::Decimal(i) => fmt::Display::fmt(&i, f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<i32> for NumericType {
|
|
||||||
fn from(x: i32) -> NumericType {
|
|
||||||
NumericType::Int(x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Decimal> for NumericType {
|
|
||||||
fn from(x: Decimal) -> NumericType {
|
|
||||||
NumericType::Decimal(x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TryFrom<NumericType> for usize {
|
|
||||||
type Error = ();
|
|
||||||
|
|
||||||
fn try_from(numeric: NumericType) -> Result<Self, Self::Error> {
|
|
||||||
match numeric {
|
|
||||||
NumericType::Int(i) => usize::try_from(i).map_err(|_| ()),
|
|
||||||
NumericType::Decimal(d) => match d.to_u64() {
|
|
||||||
Some(u) => usize::try_from(u).map_err(|_| ()),
|
|
||||||
None => Err(()),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::numeric::NumericType;
|
use crate::number::Number;
|
||||||
|
|
||||||
pub mod range;
|
pub mod range;
|
||||||
pub mod tokenize;
|
pub mod tokenize;
|
||||||
@@ -6,7 +6,7 @@ pub mod tokenize;
|
|||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ParameterValue {
|
pub enum ParameterValue {
|
||||||
Text(String),
|
Text(String),
|
||||||
Numeric(NumericType),
|
Numeric(Number),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ToString for ParameterValue {
|
impl<'a> ToString for ParameterValue {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use rust_decimal::Decimal;
|
|||||||
use super::ParameterValue;
|
use super::ParameterValue;
|
||||||
use crate::command::Command;
|
use crate::command::Command;
|
||||||
use crate::error::ParameterScanError;
|
use crate::error::ParameterScanError;
|
||||||
use crate::numeric::NumericType;
|
use crate::number::Number;
|
||||||
|
|
||||||
trait Numeric:
|
trait Numeric:
|
||||||
Add<Output = Self>
|
Add<Output = Self>
|
||||||
@@ -19,7 +19,7 @@ trait Numeric:
|
|||||||
+ Copy
|
+ Copy
|
||||||
+ Clone
|
+ Clone
|
||||||
+ From<i32>
|
+ From<i32>
|
||||||
+ Into<NumericType>
|
+ Into<Number>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<
|
impl<
|
||||||
@@ -31,7 +31,7 @@ impl<
|
|||||||
+ Copy
|
+ Copy
|
||||||
+ Clone
|
+ Clone
|
||||||
+ From<i32>
|
+ From<i32>
|
||||||
+ Into<NumericType>,
|
+ Into<Number>,
|
||||||
> Numeric for T
|
> Numeric for T
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user