Skip to content
Myr

Rename peak memory metric to memory_peak_resident

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 0d86e78 · Browse files · 10 files+57 added−54 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

10 files+57 added−54 removed

  • tests:+1 added−1 removed
  • other:+56 added−53 removed

10 files+57 added−54 removed

modified:src/benchmark/executor.rs+2 added-2 removed
275 unmodified lines
276 self.shell_spawning_time = Some(Measurement {277 time_wall_clock: measurements.time_wall_clock_mean(),278 time_user: measurements.time_user_mean(),279 time_system: measurements.time_system_mean(),280 peak_memory_usage: None,280 memory_peak_resident: None,281 exit_status: ExitStatus::default(),282 });283284 Ok(())
49 unmodified lines
334 Ok(Measurement {335 time_wall_clock: Self::extract_time(command.get_command_line()),336 time_user: Time::zero(),337 time_system: Time::zero(),338 peak_memory_usage: Some(Information::zero()),338 memory_peak_resident: Some(Information::zero()),339 exit_status,340 })341 }342
19 unmodified lines
modified:src/benchmark/measurement.rs+1 added-1 removed
47 unmodified lines
48 #[serde(49 skip_serializing_if = "Option::is_none",50 serialize_with = "serialize_optional_information"51 )]52 pub peak_memory_usage: Option<Information>,52 pub memory_peak_resident: Option<Information>,5354 // The exit status of the process55 #[serde(rename = "exit_code", serialize_with = "serialize_exit_status")]56 pub exit_status: ExitStatus,
74 unmodified lines
modified:src/benchmark/scheduler.rs+4 added-4 removed
213 unmodified lines
214 unit: second215 time_system:216 value: 0217 unit: second218 peak_memory_usage:218 memory_peak_resident:219 value: 0220 unit: byte221 exit_code: 0222 - time_wall_clock:
4 unmodified lines
227 unit: second228 time_system:229 value: 0230 unit: second231 peak_memory_usage:231 memory_peak_resident:232 value: 0233 unit: byte234 exit_code: 0235 - command: sleep 0.456
6 unmodified lines
242 unit: second243 time_system:244 value: 0245 unit: second246 peak_memory_usage:246 memory_peak_resident:247 value: 0248 unit: byte249 exit_code: 0250 - time_wall_clock:
4 unmodified lines
255 unit: second256 time_system:257 value: 0258 unit: second259 peak_memory_usage:259 memory_peak_resident:260 value: 0261 unit: byte262 exit_code: 0263 "#);
3 unmodified lines
modified:src/export/csv.rs+6 added-6 removed
85 unmodified lines
86 Measurement {87 time_wall_clock: Time::new::<second>(7.0),88 time_user: Time::new::<second>(7.0),89 time_system: Time::zero(),90 peak_memory_usage: Some(Information::new::<byte>(1024.)),90 memory_peak_resident: Some(Information::new::<byte>(1024.)),91 exit_status: ExitStatus::default(),92 },93 Measurement {94 time_wall_clock: Time::new::<second>(8.0),95 time_user: Time::new::<second>(8.0),96 time_system: Time::zero(),97 peak_memory_usage: Some(Information::new::<byte>(1024.)),97 memory_peak_resident: Some(Information::new::<byte>(1024.)),98 exit_status: ExitStatus::default(),99 },100 Measurement {101 time_wall_clock: Time::new::<second>(12.0),102 time_user: Time::new::<second>(12.0),103 time_system: Time::zero(),104 peak_memory_usage: Some(Information::new::<byte>(1024.)),104 memory_peak_resident: Some(Information::new::<byte>(1024.)),105 exit_status: ExitStatus::default(),106 },107 ]),108 parameters: {
22 unmodified lines
131 Measurement {132 time_wall_clock: Time::new::<second>(17.0),133 time_user: Time::new::<second>(17.0),134 time_system: Time::zero(),135 peak_memory_usage: Some(Information::new::<byte>(1024.)),135 memory_peak_resident: Some(Information::new::<byte>(1024.)),136 exit_status: ExitStatus::default(),137 },138 Measurement {139 time_wall_clock: Time::new::<second>(18.0),140 time_user: Time::new::<second>(18.0),141 time_system: Time::zero(),142 peak_memory_usage: Some(Information::new::<byte>(1024.)),142 memory_peak_resident: Some(Information::new::<byte>(1024.)),143 exit_status: ExitStatus::default(),144 },145 Measurement {146 time_wall_clock: Time::new::<second>(19.0),147 time_user: Time::new::<second>(19.0),148 time_system: Time::zero(),149 peak_memory_usage: Some(Information::new::<byte>(1024.)),149 memory_peak_resident: Some(Information::new::<byte>(1024.)),150 exit_status: ExitStatus::default(),151 },152 ]),153 parameters: {
33 unmodified lines
modified:src/export/json.rs+11 added-8 removed
35 unmodified lines
36 time_wall_clock: StatisticalSummary,37 time_user: StatisticalSummary,38 time_system: StatisticalSummary,39 #[serde(skip_serializing_if = "Option::is_none")]40 peak_memory_usage: Option<StatisticalSummary>,40 memory_peak_resident: Option<StatisticalSummary>,41}4243impl BenchmarkSummary {44 fn from_measurements(measurements: &Measurements) -> Self {45 let values = &measurements.measurements;46 let mut memory_values = values.iter().filter_map(|m| m.peak_memory_usage).peekable();46 let mut memory_values = values47 .iter()48 .filter_map(|m| m.memory_peak_resident)49 .peekable();50 Self {51 time_wall_clock: StatisticalSummary::from_values(52 values.iter().map(|m| m.time_wall_clock),53 second,
2 unmodified lines
56 time_system: StatisticalSummary::from_values(57 values.iter().map(|m| m.time_system),58 second,59 ),57 peak_memory_usage: memory_values60 memory_peak_resident: memory_values61 .peek()62 .is_some()63 .then(|| StatisticalSummary::from_values(memory_values, byte)),64 }
125 unmodified lines
190 let result = BenchmarkResult {191 command: "example".into(),192 name: None,193 measurements: Measurements::new(vec![Measurement {191 peak_memory_usage: memory,194 memory_peak_resident: memory,195 ..Measurement::default()196 }]),197 ..BenchmarkResult::default()198 };
36 unmodified lines
235 expected["results"][0]["summary"]["time_wall_clock"].clone();236 }237 if let Some(memory) = expected_memory {238 let value = memory["value"].clone();236 expected["results"][0]["summary"]["peak_memory_usage"] = json!({239 expected["results"][0]["summary"]["memory_peak_resident"] = json!({240 "unit": "byte", "count": 1, "mean": value,241 "stddev": null, "median": value, "min": value, "max": value242 });240 expected["results"][0]["measurements"][0]["peak_memory_usage"] = memory;243 expected["results"][0]["measurements"][0]["memory_peak_resident"] = memory;244 }245 assert_eq!(actual, expected);246 }247}
67 unmodified lines
315 .map(|(time, memory)| Measurement {316 time_wall_clock: Time::new::<second>(time),317 time_user: Time::new::<second>(time * 2.0),318 time_system: Time::new::<second>(time * 3.0),316 peak_memory_usage: memory.map(Information::new::<byte>),319 memory_peak_resident: memory.map(Information::new::<byte>),320 ..Measurement::default()321 })322 .collect(),323 );
12 unmodified lines
336 "time_system": {337 "unit": "second", "count": 3, "mean": 6.0, "stddev": 3.0,338 "median": 6.0, "min": 3.0, "max": 9.0339 },337 "peak_memory_usage": {340 "memory_peak_resident": {341 "unit": "byte", "count": 2, "mean": 2048.0,342 "stddev": 1024.0 * 2.0_f64.sqrt(),343 "median": 2048.0, "min": 1024.0, "max": 3072.0344 }
3 unmodified lines
modified:src/export/tests.rs+24 added-24 removed
32 unmodified lines
33 Measurement {34 time_wall_clock: Time::new::<second>(0.09),35 time_user: Time::new::<second>(0.09),36 time_system: Time::zero(),37 peak_memory_usage: Some(Information::new::<byte>(1024.)),37 memory_peak_resident: Some(Information::new::<byte>(1024.)),38 exit_status: ExitStatus::default(),39 },40 Measurement {41 time_wall_clock: Time::new::<second>(0.10),42 time_user: Time::new::<second>(0.10),43 time_system: Time::zero(),44 peak_memory_usage: Some(Information::new::<byte>(1024.)),44 memory_peak_resident: Some(Information::new::<byte>(1024.)),45 exit_status: ExitStatus::default(),46 },47 Measurement {48 time_wall_clock: Time::new::<second>(0.14),49 time_user: Time::new::<second>(0.14),50 time_system: Time::zero(),51 peak_memory_usage: Some(Information::new::<byte>(1024.)),51 memory_peak_resident: Some(Information::new::<byte>(1024.)),52 exit_status: ExitStatus::default(),53 },54 ]),55 parameters: BTreeMap::new(),
5 unmodified lines
61 Measurement {62 time_wall_clock: Time::new::<second>(2.0),63 time_user: Time::new::<second>(2.0),64 time_system: Time::zero(),65 peak_memory_usage: Some(Information::new::<byte>(1024.)),65 memory_peak_resident: Some(Information::new::<byte>(1024.)),66 exit_status: ExitStatus::default(),67 },68 Measurement {69 time_wall_clock: Time::new::<second>(3.0),70 time_user: Time::new::<second>(3.0),71 time_system: Time::zero(),72 peak_memory_usage: Some(Information::new::<byte>(1024.)),72 memory_peak_resident: Some(Information::new::<byte>(1024.)),73 exit_status: ExitStatus::default(),74 },75 Measurement {76 time_wall_clock: Time::new::<second>(4.0),77 time_user: Time::new::<second>(4.0),78 time_system: Time::zero(),79 peak_memory_usage: Some(Information::new::<byte>(1024.)),79 memory_peak_resident: Some(Information::new::<byte>(1024.)),80 exit_status: ExitStatus::default(),81 },82 ]),83 parameters: BTreeMap::new(),
50 unmodified lines
134 Measurement {135 time_wall_clock: Time::new::<second>(2.1),136 time_user: Time::new::<second>(2.1),137 time_system: Time::zero(),138 peak_memory_usage: Some(Information::new::<byte>(1024.)),138 memory_peak_resident: Some(Information::new::<byte>(1024.)),139 exit_status: ExitStatus::default(),140 },141 Measurement {142 time_wall_clock: Time::new::<second>(2.2),143 time_user: Time::new::<second>(2.2),144 time_system: Time::zero(),145 peak_memory_usage: Some(Information::new::<byte>(1024.)),145 memory_peak_resident: Some(Information::new::<byte>(1024.)),146 exit_status: ExitStatus::default(),147 },148 Measurement {149 time_wall_clock: Time::new::<second>(2.3),150 time_user: Time::new::<second>(2.3),151 time_system: Time::zero(),152 peak_memory_usage: Some(Information::new::<byte>(1024.)),152 memory_peak_resident: Some(Information::new::<byte>(1024.)),153 exit_status: ExitStatus::default(),154 },155 ]),156 parameters: BTreeMap::new(),
5 unmodified lines
162 Measurement {163 time_wall_clock: Time::new::<second>(0.1),164 time_user: Time::new::<second>(0.1),165 time_system: Time::zero(),166 peak_memory_usage: Some(Information::new::<byte>(1024.)),166 memory_peak_resident: Some(Information::new::<byte>(1024.)),167 exit_status: ExitStatus::default(),168 },169 Measurement {170 time_wall_clock: Time::new::<second>(0.2),171 time_user: Time::new::<second>(0.2),172 time_system: Time::zero(),173 peak_memory_usage: Some(Information::new::<byte>(1024.)),173 memory_peak_resident: Some(Information::new::<byte>(1024.)),174 exit_status: ExitStatus::default(),175 },176 Measurement {177 time_wall_clock: Time::new::<second>(0.3),178 time_user: Time::new::<second>(0.3),179 time_system: Time::zero(),180 peak_memory_usage: Some(Information::new::<byte>(1024.)),180 memory_peak_resident: Some(Information::new::<byte>(1024.)),181 exit_status: ExitStatus::default(),182 },183 ]),184 parameters: BTreeMap::new(),
50 unmodified lines
235 Measurement {236 time_wall_clock: Time::new::<second>(2.1),237 time_user: Time::new::<second>(2.1),238 time_system: Time::zero(),239 peak_memory_usage: Some(Information::new::<byte>(1024.)),239 memory_peak_resident: Some(Information::new::<byte>(1024.)),240 exit_status: ExitStatus::default(),241 },242 Measurement {243 time_wall_clock: Time::new::<second>(2.2),244 time_user: Time::new::<second>(2.2),245 time_system: Time::zero(),246 peak_memory_usage: Some(Information::new::<byte>(1024.)),246 memory_peak_resident: Some(Information::new::<byte>(1024.)),247 exit_status: ExitStatus::default(),248 },249 Measurement {250 time_wall_clock: Time::new::<second>(2.3),251 time_user: Time::new::<second>(2.3),252 time_system: Time::zero(),253 peak_memory_usage: Some(Information::new::<byte>(1024.)),253 memory_peak_resident: Some(Information::new::<byte>(1024.)),254 exit_status: ExitStatus::default(),255 },256 ]),257 parameters: BTreeMap::new(),
5 unmodified lines
263 Measurement {264 time_wall_clock: Time::new::<second>(0.1),265 time_user: Time::new::<second>(0.1),266 time_system: Time::zero(),267 peak_memory_usage: Some(Information::new::<byte>(1024.)),267 memory_peak_resident: Some(Information::new::<byte>(1024.)),268 exit_status: ExitStatus::default(),269 },270 Measurement {271 time_wall_clock: Time::new::<second>(0.2),272 time_user: Time::new::<second>(0.2),273 time_system: Time::zero(),274 peak_memory_usage: Some(Information::new::<byte>(1024.)),274 memory_peak_resident: Some(Information::new::<byte>(1024.)),275 exit_status: ExitStatus::default(),276 },277 Measurement {278 time_wall_clock: Time::new::<second>(0.3),279 time_user: Time::new::<second>(0.3),280 time_system: Time::zero(),281 peak_memory_usage: Some(Information::new::<byte>(1024.)),281 memory_peak_resident: Some(Information::new::<byte>(1024.)),282 exit_status: ExitStatus::default(),283 },284 ]),285 parameters: BTreeMap::new(),
49 unmodified lines
335 Measurement {336 time_wall_clock: Time::new::<second>(2.01),337 time_user: Time::new::<second>(2.01),338 time_system: Time::zero(),339 peak_memory_usage: Some(Information::new::<byte>(1024.)),339 memory_peak_resident: Some(Information::new::<byte>(1024.)),340 exit_status: ExitStatus::default(),341 },342 Measurement {343 time_wall_clock: Time::new::<second>(2.02),344 time_user: Time::new::<second>(2.02),345 time_system: Time::zero(),346 peak_memory_usage: Some(Information::new::<byte>(1024.)),346 memory_peak_resident: Some(Information::new::<byte>(1024.)),347 exit_status: ExitStatus::default(),348 },349 Measurement {350 time_wall_clock: Time::new::<second>(2.03),351 time_user: Time::new::<second>(2.03),352 time_system: Time::zero(),353 peak_memory_usage: Some(Information::new::<byte>(1024.)),353 memory_peak_resident: Some(Information::new::<byte>(1024.)),354 exit_status: ExitStatus::default(),355 },356 ]),357 parameters: BTreeMap::new(),
5 unmodified lines
363 Measurement {364 time_wall_clock: Time::new::<second>(0.11),365 time_user: Time::new::<second>(0.11),366 time_system: Time::zero(),367 peak_memory_usage: Some(Information::new::<byte>(1024.)),367 memory_peak_resident: Some(Information::new::<byte>(1024.)),368 exit_status: ExitStatus::default(),369 },370 Measurement {371 time_wall_clock: Time::new::<second>(0.12),372 time_user: Time::new::<second>(0.12),373 time_system: Time::zero(),374 peak_memory_usage: Some(Information::new::<byte>(1024.)),374 memory_peak_resident: Some(Information::new::<byte>(1024.)),375 exit_status: ExitStatus::default(),376 },377 Measurement {378 time_wall_clock: Time::new::<second>(0.13),379 time_user: Time::new::<second>(0.13),380 time_system: Time::zero(),381 peak_memory_usage: Some(Information::new::<byte>(1024.)),381 memory_peak_resident: Some(Information::new::<byte>(1024.)),382 exit_status: ExitStatus::default(),383 },384 ]),385 parameters: BTreeMap::new(),
40 unmodified lines
modified:src/quantity/mod.rs+4 added-4 removed
220 unmodified lines
221 assert_eq!(time.format(TimeUnit::MilliSecond), "123.4 ms");222 assert_eq!(time.format_auto(), "123.4 ms");223 assert_eq!(time.format(TimeUnit::MicroSecond), "123400.0 µs");224225 let peak_memory_usage = Information::new::<kibibyte>(8.);226 assert_eq!(peak_memory_usage.format_auto(), "8.0 KiB");227 assert_eq!(peak_memory_usage.format(InformationUnit::Byte), "8192 B");225 let memory_peak_resident = Information::new::<kibibyte>(8.);226 assert_eq!(memory_peak_resident.format_auto(), "8.0 KiB");227 assert_eq!(memory_peak_resident.format(InformationUnit::Byte), "8192 B");228 assert_eq!(229 peak_memory_usage.format(InformationUnit::KibiByte),229 memory_peak_resident.format(InformationUnit::KibiByte),230 "8.0 KiB"231 );232}233
11 unmodified lines
modified:src/timer/mod.rs+2 added-2 removed
80 unmodified lines
81 // Handle CommandOutputPolicy::Pipe82 discard(output);83 }8485 let (time_user, time_system, peak_memory_usage, exit_status) = cpu_timer.stop(child)?;85 let (time_user, time_system, memory_peak_resident, exit_status) = cpu_timer.stop(child)?;86 let time_wall_clock = wallclock_timer.stop();8788 Ok(Measurement {89 time_wall_clock,90 time_user,91 time_system,92 peak_memory_usage,92 memory_peak_resident,93 exit_status,94 })95}
modified:tests/integration_tests.rs+1 added-1 removed
110 unmodified lines
111 .unwrap();112 assert!(output.status.success());113 let export: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();114 let measurement = &export["results"][0]["measurements"][0];115 let memory = measurement.get("peak_memory_usage");115 let memory = measurement.get("memory_peak_resident");116 if cfg!(windows) {117 assert!(memory.is_none(), "unavailable memory must be omitted");118 } else {119 let memory = memory.expect("Unix memory measurement must be present");
1236 unmodified lines
modified:README.md+2 added-2 removed
163 unmodified lines
164|:---|:---|:---|165| `time_wall_clock` | second | Elapsed time, including time spent waiting or descheduled. Available on all platforms. |166| `time_user` | second | CPU time spent in user mode, accumulated across threads. On Unix, includes descendants whose usage propagates through parents waiting for them. On Windows, includes processes associated with the benchmark's job object. |167| `time_system` | second | CPU time spent in kernel mode, with the same process accounting as `time_user`. |168| `peak_memory_usage` | byte | Peak resident set size (RSS) on Linux and macOS; omitted on Windows. This is the largest per-process peak among the command and descendants whose usage is collected by waiting for them, **not the simultaneous total memory of the process tree**. Linux's KiB counter and macOS's byte counter are both exported in bytes. On macOS, this is RSS, not Apple's separate memory-footprint metric. |168| `memory_peak_resident` | byte | Peak resident set size (RSS) on Linux and macOS; omitted on Windows. This is the largest per-process peak among the command and descendants whose usage is collected by waiting for them, **not the simultaneous total memory of the process tree**. Linux's KiB counter and macOS's byte counter are both exported in bytes. On macOS, this is RSS, not Apple's separate memory-footprint metric. |169170Metrics unavailable on a platform are omitted, rather than reported as zero. Time values are always171exported in seconds, regardless of `--time-unit`. When using a shell, the estimated shell startup172CPU and wall-clock times are subtracted; memory usage is not adjusted.173174For example, two concurrent worker processes that each use 128 MiB can produce a175`peak_memory_usage` of about 128 MiB, even though their combined memory use is about 256 MiB.175`memory_peak_resident` of about 128 MiB, even though their combined memory use is about 256 MiB.176Threads share a process's address space and are covered by its RSS measurement.177178The JSON output is useful if you want to analyze the benchmark results in more detail. The179[`scripts/`](https://github.com/sharkdp/hyperfine/tree/master/scripts) folder includes a lot
192 unmodified lines