Add short unit
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 a119cba · Browse files · 2 files·+86 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+86 added−17 removed
- other:+86 added−17 removed
Provenance
- Commit
9ec7a9c- Tree
b4a1159- Author
David Peter <sharkdp@users.noreply.github.com>- Committer
David Peter <mail@david-peter.de>- Parent
a119cba
2 files changed+86 added−17 removed
modified:src/benchmark/quantity.rs+22 added-1 removed
83 unmodified lines84 85 self.086 }87 88+ const fn unit_name(&self) -> &'static str {89+ match (IS_TIME, IS_INFORMATION) {90+ (true, false) => match METRIC_PREFIX_TIME {91+ -6 => "µs",92+ -3 => "ms",93+ 0 => "s",94+ _ => unreachable!(),95+ },96+ (false, true) => match BINARY_PREFIX_INFORMATION {97+ 0 => "B",98+ 10 => "KiB",99+ 20 => "MiB",100+ 30 => "GiB",101+ 40 => "TiB",102+ _ => unreachable!(),103+ },104+ _ => unreachable!(),105+ }106+ }107+108 const fn unit_name_long(&self) -> &'static str {109 match (IS_TIME, IS_INFORMATION) {110 (true, false) => match METRIC_PREFIX_TIME {111 -6 => "microsecond",86 unmodified lines198 S: Serializer,199 {200 let mut state = serializer.serialize_struct("Quantity", 2)?;201 state.serialize_field("value", &self.0)?;182- state.serialize_field("unit", self.unit_name_long())?;202+ state.serialize_field("unit", self.unit_name())?;203+ state.serialize_field("unit_long", self.unit_name_long())?;204 state.end()205 }206 }207 59 unmodified linesmodified:src/benchmark/scheduler.rs+64 added-16 removed
204 unmodified lines205 fn scheduler_basic() -> Result<()> {206 insta::assert_yaml_snapshot!(generate_results(&["--runs=2", "sleep 0.123", "sleep 0.456"])?, @r#"207 - command: sleep 0.123208 measurements:209- - time_wall_clock: 0.123210- time_user: 0211- time_system: 0212- peak_memory_usage: 0209+ - time_wall_clock:210+ value: 0.123211+ unit: s212+ unit_long: second213+ time_user:214+ value: 0215+ unit: s216+ unit_long: second217+ time_system:218+ value: 0219+ unit: s220+ unit_long: second221+ peak_memory_usage:222+ value: 0223+ unit: B224+ unit_long: byte225 exit_code: 0214- - time_wall_clock: 0.123215- time_user: 0216- time_system: 0217- peak_memory_usage: 0226+ - time_wall_clock:227+ value: 0.123228+ unit: s229+ unit_long: second230+ time_user:231+ value: 0232+ unit: s233+ unit_long: second234+ time_system:235+ value: 0236+ unit: s237+ unit_long: second238+ peak_memory_usage:239+ value: 0240+ unit: B241+ unit_long: byte242 exit_code: 0243 - command: sleep 0.456244 measurements:221- - time_wall_clock: 0.456222- time_user: 0223- time_system: 0224- peak_memory_usage: 0245+ - time_wall_clock:246+ value: 0.456247+ unit: s248+ unit_long: second249+ time_user:250+ value: 0251+ unit: s252+ unit_long: second253+ time_system:254+ value: 0255+ unit: s256+ unit_long: second257+ peak_memory_usage:258+ value: 0259+ unit: B260+ unit_long: byte261 exit_code: 0226- - time_wall_clock: 0.456227- time_user: 0228- time_system: 0229- peak_memory_usage: 0262+ - time_wall_clock:263+ value: 0.456264+ unit: s265+ unit_long: second266+ time_user:267+ value: 0268+ unit: s269+ unit_long: second270+ time_system:271+ value: 0272+ unit: s273+ unit_long: second274+ peak_memory_usage:275+ value: 0276+ unit: B277+ unit_long: byte278 exit_code: 0279 "#);280 281 Ok(())1 unmodified line