Remove alternative constructors

This commit is contained in:
David Peter authored and David Peter committed 2026-10-05 15:59:43 +02:00
1 parent f57c4e6d78
commit 3494c8abe6
8 files changed
+112 -113

No files matched your search

+4 -4
View File
@@ -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((
+3 -3
View File
@@ -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)
}
}
+3 -3
View File
@@ -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 {