mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-10-30 16:40:18 +00:00
Remove alternative constructors
This commit is contained in:
1 parent
f57c4e6d78
commit
3494c8abe6
8 files changed
+112
-113
No files matched your search
@@ -8,7 +8,7 @@ use std::process::{Child, ExitStatus};
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};
|
||||
use crate::quantity::{byte, kibibyte, microsecond, second, Information, Time};
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
struct ResourceUsage {
|
||||
@@ -27,7 +27,7 @@ fn convert_timeval(tv: libc::timeval) -> Time {
|
||||
let sec = tv.tv_sec as f64;
|
||||
let usec = tv.tv_usec as f64;
|
||||
|
||||
Time::from_seconds(sec) + Time::from_microseconds(usec)
|
||||
Time::new::<second>(sec) + Time::new::<microsecond>(usec)
|
||||
}
|
||||
|
||||
#[allow(clippy::useless_conversion)]
|
||||
@@ -47,9 +47,9 @@ fn wait4(mut child: Child) -> io::Result<(ExitStatus, ResourceUsage)> {
|
||||
|
||||
let memory_usage_byte = if cfg!(target_os = "macos") || cfg!(target_os = "ios") {
|
||||
// Linux and *BSD return the value in KibiBytes, Darwin flavors in bytes
|
||||
Information::from_bytes(u64::try_from(rusage.ru_maxrss).unwrap_or(0))
|
||||
Information::new::<byte>(u64::try_from(rusage.ru_maxrss).unwrap_or(0))
|
||||
} else {
|
||||
Information::from_kibibytes(u64::try_from(rusage.ru_maxrss).unwrap_or(0))
|
||||
Information::new::<kibibyte>(u64::try_from(rusage.ru_maxrss).unwrap_or(0))
|
||||
};
|
||||
|
||||
Ok((
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::time::Instant;
|
||||
|
||||
use crate::quantity::{Time, TimeQuantity};
|
||||
use crate::quantity::{nanosecond, second, Time};
|
||||
|
||||
pub struct WallClockTimer {
|
||||
start: Instant,
|
||||
@@ -16,7 +16,7 @@ impl WallClockTimer {
|
||||
pub fn stop(&self) -> Time {
|
||||
let duration = self.start.elapsed();
|
||||
|
||||
Time::from_seconds(duration.as_secs() as f64)
|
||||
+ Time::from_nanoseconds(duration.subsec_nanos() as f64)
|
||||
Time::new::<second>(duration.as_secs() as f64)
|
||||
+ Time::new::<nanosecond>(duration.subsec_nanos() as f64)
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ use windows_sys::{
|
||||
},
|
||||
};
|
||||
|
||||
use crate::quantity::{Information, InformationQuantity, Time, TimeQuantity};
|
||||
use crate::quantity::{nanosecond, Information, InformationQuantity, Time};
|
||||
|
||||
#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
|
||||
#[allow(non_upper_case_globals)]
|
||||
@@ -108,13 +108,13 @@ impl CPUTimer {
|
||||
// The `TotalUserTime` is "The total amount of user-mode execution time for
|
||||
// all active processes associated with the job, as well as all terminated processes no
|
||||
// longer associated with the job, in 100-nanosecond ticks."
|
||||
let user_time = Time::from_nanoseconds((job_object_info.TotalUserTime as f64) * 100.0);
|
||||
let user_time = Time::new::<nanosecond>((job_object_info.TotalUserTime as f64) * 100.0);
|
||||
|
||||
// The `TotalKernelTime` is "The total amount of kernel-mode execution time
|
||||
// for all active processes associated with the job, as well as all terminated
|
||||
// processes no longer associated with the job, in 100-nanosecond ticks."
|
||||
let system_time =
|
||||
Time::from_nanoseconds((job_object_info.TotalKernelTime as f64) * 100.0);
|
||||
Time::new::<nanosecond>((job_object_info.TotalKernelTime as f64) * 100.0);
|
||||
|
||||
Ok((user_time, system_time, Information::zero(), status))
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user