Struct dsi_progress_logger::ProgressLogger
source · pub struct ProgressLogger<'a> {
pub item_name: &'a str,
pub log_interval: Duration,
pub expected_updates: Option<usize>,
pub time_unit: Option<TimeUnit>,
pub local_speed: bool,
/* private fields */
}
Fields§
§item_name: &'a str
The name of an item. Defaults to item
.
log_interval: Duration
The log interval. Defaults to 10 seconds.
expected_updates: Option<usize>
The expected number of updates. If set, the logger will display the percentage of completion and an estimate of the time to completion.
time_unit: Option<TimeUnit>
The time unit to use for speed. If set, the logger will always display the speed in this unit instead of making a choice of readable unit based on the elapsed time. Moreover, large numbers will not be thousands separated. This is useful when the output of the logger must be parsed.
local_speed: bool
Display additionally the speed achieved during the last log interval.
Implementations§
source§impl<'a> ProgressLogger<'a>
impl<'a> ProgressLogger<'a>
sourcepub const LIGHT_UPDATE_MASK: usize = 1_048_575usize
pub const LIGHT_UPDATE_MASK: usize = 1_048_575usize
Calls to light_update will cause a call to
Instant::now
only if the current count
is a multiple of this mask plus one.
sourcepub fn display_memory(self) -> Self
pub fn display_memory(self) -> Self
Chainable setter enabling memory display.
sourcepub fn refresh(&mut self)
pub fn refresh(&mut self)
Refresh memory information, if previously requested with display_memory
.
You do not need to call this method unless you display the logger manually.
sourcepub fn update_with_count(&mut self, count: usize)
pub fn update_with_count(&mut self, count: usize)
Set the count and check whether it is time to log.
sourcepub fn light_update(&mut self)
pub fn light_update(&mut self)
Increase the count and, once every LIGHT_UPDATE_MASK
+ 1 calls, check whether it is time to log.
sourcepub fn update_and_display(&mut self)
pub fn update_and_display(&mut self)
Increase the count and force a log.
sourcepub fn done(&mut self)
pub fn done(&mut self)
Stop the logger, print Completed.
, and display the final stats. The number of expected updates will be cleared.
sourcepub fn done_with_count(&mut self, count: usize)
pub fn done_with_count(&mut self, count: usize)
Stop the logger, set the count, print Completed.
, and display the final stats.
The number of expected updates will be cleared.
This method is particularly useful in two circumstances:
- you have updated the logger with some approximate values (e.g., in a multicore computation) but before printing the final stats you want the internal counter to contain an exact value;
- you have used the logger as a handy timer, calling just
start
and this method.