mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-16 09:21:27 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4fb20f85b |
No files matched your search
+5
-3
@@ -19,6 +19,8 @@ impl Exporter for CsvExporter {
|
||||
_unit: Option<TimeUnit>,
|
||||
_sort_order: SortOrder,
|
||||
) -> Result<Vec<u8>> {
|
||||
const CSV_PRECISION: usize = 6;
|
||||
|
||||
let mut writer = WriterBuilder::new().from_writer(vec![]);
|
||||
|
||||
{
|
||||
@@ -48,7 +50,7 @@ impl Exporter for CsvExporter {
|
||||
res.min,
|
||||
res.max,
|
||||
] {
|
||||
fields.push(Cow::Owned(f.to_string().into_bytes()))
|
||||
fields.push(Cow::Owned(format!("{f:.CSV_PRECISION$}").into_bytes()))
|
||||
}
|
||||
for v in res.parameters.values() {
|
||||
fields.push(Cow::Borrowed(v.as_bytes()))
|
||||
@@ -117,7 +119,7 @@ fn test_csv() {
|
||||
|
||||
insta::assert_snapshot!(actual, @r#"
|
||||
command,mean,stddev,median,user,system,min,max,parameter_bar,parameter_foo
|
||||
command_a,1,2,1,3,4,5,6,two,one
|
||||
command_b,11,12,11,13,14,15,16.5,seven,one
|
||||
command_a,1.000000,2.000000,1.000000,3.000000,4.000000,5.000000,6.000000,two,one
|
||||
command_b,11.000000,12.000000,11.000000,13.000000,14.000000,15.000000,16.500000,seven,one
|
||||
"#);
|
||||
}
|
||||
+1
-3
@@ -4,9 +4,7 @@ pub use uom::num_traits::Zero;
|
||||
pub use uom::si::f64::{Information, Ratio, Time};
|
||||
pub use uom::si::information::byte;
|
||||
pub use uom::si::ratio::ratio;
|
||||
#[cfg(any(not(windows), test))]
|
||||
pub use uom::si::time::microsecond;
|
||||
pub use uom::si::time::{nanosecond, second};
|
||||
pub use uom::si::time::{microsecond, nanosecond, second};
|
||||
|
||||
pub use units::TimeUnit;
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ use windows_sys::{
|
||||
},
|
||||
};
|
||||
|
||||
use crate::quantity::{nanosecond, Information, Time, Zero};
|
||||
use crate::quantity::{microsecond, Information, Time, Zero};
|
||||
|
||||
const HUNDRED_NS_PER_MS: i64 = 10;
|
||||
|
||||
#[cfg(not(feature = "windows_process_extensions_main_thread_handle"))]
|
||||
#[allow(non_upper_case_globals)]
|
||||
@@ -106,14 +108,17 @@ 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::new::<nanosecond>((job_object_info.TotalUserTime as f64) * 100.0);
|
||||
let user: i64 = job_object_info.TotalUserTime / HUNDRED_NS_PER_MS;
|
||||
|
||||
// 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::new::<nanosecond>((job_object_info.TotalKernelTime as f64) * 100.0);
|
||||
(user_time, system_time, Information::zero())
|
||||
let kernel: i64 = job_object_info.TotalKernelTime / HUNDRED_NS_PER_MS;
|
||||
(
|
||||
Time::new::<microsecond>(user as f64),
|
||||
Time::new::<microsecond>(kernel as f64),
|
||||
Information::zero(),
|
||||
)
|
||||
} else {
|
||||
(Time::zero(), Time::zero(), Information::zero())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user