mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +00:00
Use uom
This commit is contained in:
1 parent
9ec7a9c920
commit
641451aea6
15 files changed
+459
-443
No files matched your search
@@ -12,7 +12,7 @@ use std::time::Instant;
|
||||
use crate::benchmark::benchmark_result::Parameter;
|
||||
use crate::benchmark::executor::BenchmarkIteration;
|
||||
use crate::benchmark::measurement::{Measurement, Measurements};
|
||||
use crate::benchmark::quantity::{MilliSecond, Second};
|
||||
use crate::benchmark::quantity::{const_time_from_seconds, Time, TimeQuantity};
|
||||
use crate::command::Command;
|
||||
use crate::options::{
|
||||
CmdFailureAction, CommandOutputPolicy, ExecutorKind, Options, OutputStyleOption,
|
||||
@@ -33,7 +33,7 @@ use colored::*;
|
||||
use self::executor::Executor;
|
||||
|
||||
/// Threshold for warning about fast execution time
|
||||
pub const MIN_EXECUTION_TIME: MilliSecond = MilliSecond::new(5.);
|
||||
pub const MIN_EXECUTION_TIME: Time = const_time_from_seconds(0.005);
|
||||
|
||||
pub struct Benchmark<'a> {
|
||||
number: usize,
|
||||
@@ -262,7 +262,7 @@ impl<'a> Benchmark<'a> {
|
||||
};
|
||||
|
||||
let preparation_result = run_preparation_command()?;
|
||||
let preparation_overhead = preparation_result.map_or(Second::zero(), |res| {
|
||||
let preparation_overhead = preparation_result.map_or(Time::zero(), |res| {
|
||||
res.time_wall_clock + self.executor.time_overhead()
|
||||
});
|
||||
|
||||
@@ -291,7 +291,7 @@ impl<'a> Benchmark<'a> {
|
||||
}
|
||||
|
||||
let conclusion_result = run_conclusion_command()?;
|
||||
let conclusion_overhead = conclusion_result.map_or(Second::zero(), |res| {
|
||||
let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| {
|
||||
res.time_wall_clock + self.executor.time_overhead()
|
||||
});
|
||||
|
||||
@@ -301,7 +301,7 @@ impl<'a> Benchmark<'a> {
|
||||
+ self.executor.time_overhead()
|
||||
+ preparation_overhead
|
||||
+ conclusion_overhead))
|
||||
.get::<ratio>() as u64;
|
||||
.get::<quantity::ratio>() as u64;
|
||||
|
||||
let count = {
|
||||
let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);
|
||||
@@ -432,7 +432,7 @@ impl<'a> Benchmark<'a> {
|
||||
&& measurements
|
||||
.wall_clock_times()
|
||||
.iter()
|
||||
.any(|&t| t < MIN_EXECUTION_TIME.convert_to::<Second>())
|
||||
.any(|&t| t < MIN_EXECUTION_TIME)
|
||||
{
|
||||
warnings.push(Warnings::FastExecutionTime);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user