Use wait4 instead of getrusage

This commit is contained in:
David Peter authored and David Peter committed 2026-10-05 15:56:37 +02:00
1 parent 50232feb22
commit ae0035ad56
9 files changed
+143 -98

No files matched your search

+6 -7
View File
@@ -18,6 +18,12 @@ pub struct BenchmarkRun {
/// Time spent in kernel mode
pub system_time: Second,
/// Maximum memory usage of the process, in bytes
pub memory_usage_byte: u64,
/// Exit codes of the process
pub exit_code: Option<i32>,
}
use crate::benchmark::measurement::Measurements;
@@ -45,13 +51,6 @@ pub struct BenchmarkResult {
/// All run time measurements
pub runs: Vec<BenchmarkRun>,
/// Maximum memory usage of the process, in bytes
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_usage_byte: Option<Vec<u64>>,
/// Exit codes of all command invocations
pub exit_codes: Vec<Option<i32>>,
/// Parameter values for this benchmark
pub parameters: BTreeMap<String, Parameter>,
}
+18 -8
View File
@@ -492,15 +492,25 @@ impl<'a> Benchmark<'a> {
command_with_unused_parameters: self.command.get_name_with_unused_parameters(),
runs: times_real
.iter()
.zip(times_user.iter().zip(times_system.iter()))
.map(|(wall_clock_time, (user_time, system_time))| BenchmarkRun {
wall_clock_time: *wall_clock_time,
user_time: *user_time,
system_time: *system_time,
})
.zip(times_user.iter())
.zip(times_system.iter())
.zip(memory_usage_byte.iter())
.zip(exit_codes.iter())
.map(
|(
(((wall_clock_time, user_time), system_time), memory_usage_byte),
exit_code,
)| {
BenchmarkRun {
wall_clock_time: *wall_clock_time,
user_time: *user_time,
system_time: *system_time,
memory_usage_byte: *memory_usage_byte,
exit_code: *exit_code,
}
},
)
.collect(),
memory_usage_byte: Some(memory_usage_byte),
exit_codes,
parameters: self
.command
.get_parameters()
+2 -2
View File
@@ -156,9 +156,9 @@ fn create_result(name: &str, mean: f64) -> BenchmarkResult {
wall_clock_time: mean,
user_time: mean,
system_time: 0.,
memory_usage_byte: 1024,
exit_code: Some(0),
}],
memory_usage_byte: None,
exit_codes: Vec::new(),
parameters: BTreeMap::new(),
}
}
+8 -12
View File
@@ -209,29 +209,25 @@ fn scheduler_basic() -> Result<()> {
- wall_clock_time: 0.123
user_time: 0
system_time: 0
memory_usage_byte: 0
exit_code: 0
- wall_clock_time: 0.123
user_time: 0
system_time: 0
memory_usage_byte:
- 0
- 0
exit_codes:
- 0
- 0
memory_usage_byte: 0
exit_code: 0
- command: sleep 0.456
runs:
- wall_clock_time: 0.456
user_time: 0
system_time: 0
memory_usage_byte: 0
exit_code: 0
- wall_clock_time: 0.456
user_time: 0
system_time: 0
memory_usage_byte:
- 0
- 0
exit_codes:
- 0
- 0
memory_usage_byte: 0
exit_code: 0
"#);
Ok(())