Skip to content
Myr

Serialize command parameters to data output files

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

This patch adds any parameter used to data output files (currently JSON and CSV files). With that users have direct access to both input values (i.e., benchmark parameters) and the resulting timings which should simplify follow-up analyses.

authored by Benjamin Bannier · committed by David Peter · parent 9afe57d · Browse files · 3 files+15 added−0 removed
This commit

State

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

Diff stats

3 files+15 added−0 removed

  • other:+15 added−0 removed

3 files+15 added−0 removed

modified:src/hyperfine/export/markdown.rs+8 added
81 unmodified lines
82 0.0011, // system_mean83 0.1023, // min84 0.1080, // max85 vec![0.1, 0.1, 0.1], // times86 None, // parameter87 ));8889 timing_results.push(BenchmarkResult::new(90 String::from("sleep 2"),
3 unmodified lines
94 0.0012, // system_mean95 2.0020, // min96 2.0080, // max97 vec![2.0, 2.0, 2.0], // times98 None, // parameter99 ));100101 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();102
24 unmodified lines
127 0.0012, // system_mean128 2.0020, // min129 2.0080, // max130 vec![2.0, 2.0, 2.0], // times131 None, // parameter132 ));133134 timing_results.push(BenchmarkResult::new(135 String::from("sleep 0.1"),
3 unmodified lines
139 0.0011, // system_mean140 0.1023, // min141 0.1080, // max142 vec![0.1, 0.1, 0.1], // times143 None, // parameter144 ));145146 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();147
23 unmodified lines
171 0.0011, // system_mean172 0.1023, // min173 0.1080, // max174 vec![0.1, 0.1, 0.1], // times175 None, // parameter176 ));177178 timing_results.push(BenchmarkResult::new(179 String::from("sleep 2"),
3 unmodified lines
183 0.0012, // system_mean184 2.0020, // min185 2.0080, // max186 vec![2.0, 2.0, 2.0], // times187 None, // parameter188 ));189190 let formatted = String::from_utf8(191 exporter
29 unmodified lines
221 0.0012, // system_mean222 2.0020, // min223 2.0080, // max224 vec![2.0, 2.0, 2.0], // times225 None, // parameter226 ));227228 timing_results.push(BenchmarkResult::new(229 String::from("sleep 0.1"),
3 unmodified lines
233 0.0011, // system_mean234 0.1023, // min235 0.1080, // max236 vec![0.1, 0.1, 0.1], // times237 None, // parameter238 ));239240 let formatted = String::from_utf8(241 exporter
15 unmodified lines
modified:src/hyperfine/benchmark.rs+1 added
410 unmodified lines
411 system_mean,412 t_min,413 t_max,414 times_real,415 cmd.get_parameter().map(|p| p.1),416 ))417}
modified:src/hyperfine/types.rs+6 added
171 unmodified lines
172173 /// All run time measurements174 #[serde(skip_serializing_if = "Option::is_none")]175 pub times: Option<Vec<Second>>,176177 /// Any parameter used178 #[serde(skip_serializing_if = "Option::is_none")]179 pub parameter: Option<i32>,180}181182impl BenchmarkResult {183 /// Create a new entry with the given values.
5 unmodified lines
189 system: Second,190 min: Second,191 max: Second,192 times: Vec<Second>,193 parameter: Option<i32>,194 ) -> Self {195 BenchmarkResult {196 command,197 mean,
2 unmodified lines
200 system,201 min,202 max,203 times: Some(times),204 parameter,205 }206 }207}