pub enum TimeUnit {
NanoSeconds,
MicroSeconds,
MilliSeconds,
Seconds,
Minutes,
Hours,
Days,
}Expand description
A unit of time, from nanoseconds to days.
Time units are used to display timings and speeds. Usually the most
convenient unit is chosen automatically, but you can fix a specific unit
with ProgressLog::time_unit.
Variants§
NanoSeconds
A nanosecond (10⁻⁹ seconds).
MicroSeconds
A microsecond (10⁻⁶ seconds).
MilliSeconds
A millisecond (10⁻³ seconds).
Seconds
A second.
Minutes
A minute (60 seconds).
Hours
An hour (3600 seconds).
Days
A day (86400 seconds).
Implementations§
Source§impl TimeUnit
impl TimeUnit
Sourcepub const fn label(&self) -> &'static str
pub const fn label(&self) -> &'static str
Returns the label used to display this time unit (e.g., s for
Seconds).
Sourcepub const fn as_seconds(&self) -> f64
pub const fn as_seconds(&self) -> f64
Returns the length of this time unit in seconds.
Sourcepub const fn nice_time_unit(seconds: f64) -> Self
pub const fn nice_time_unit(seconds: f64) -> Self
Returns the largest time unit not exceeding the given duration in seconds; it is used to display per-item timings.
For durations shorter than a nanosecond,
NanoSeconds is returned.
Sourcepub const fn nice_speed_unit(seconds: f64) -> Self
pub const fn nice_speed_unit(seconds: f64) -> Self
Sourcepub fn pretty_print(milliseconds: u128) -> String
pub fn pretty_print(milliseconds: u128) -> String
Pretty-prints a duration expressed in milliseconds.
Durations of less than a second are displayed as {}ms; longer
durations are displayed as days, hours, minutes, and seconds (e.g.,
1d 3h 10m 5s), discarding the sub-second part.