[−][src]Struct progress_logger::ProgressLogger
A tool to report the progress of computations. It can be built and configured
using the builder
function. If given the expected number of updates,
reports the expected time to completion, based on the current throughtput.
Progress is reported every 10 seconds by default. See the examples about how to change it.
There are three methods to update the internal counter:
update
, for events that don't happen frequentlyupdate_light
, which tries to report (by checking the configured frequency of updates) only once every million updates. To be used in situations where updates are frequent: it's an order of magnitude faster thanupdate
.
Reports are issued on the console using the info!()
macro from the log
crate.
Therefore, the reports depend on your logging configuration.
Inspired by ProgressLogger
in the dsiutil
Java library.
Examples
Basic usage
use progress_logger::ProgressLogger; let mut pl = ProgressLogger::builder().start(); let mut cnt = 0; for i in 0..10000 { cnt += 1; pl.update(1u32); } pl.stop();
Reporting every 5 seconds
use progress_logger::ProgressLogger; use std::time::Duration; let mut pl = ProgressLogger::builder() .with_frequency(Duration::from_secs(5)) .start(); let mut cnt = 0; for i in 0..10000 { cnt += 1; pl.update(1u32); } pl.stop();
Changing the names of updates
use progress_logger::ProgressLogger; let mut pl = ProgressLogger::builder() .with_items_name("points") .start(); let mut cnt = 0; for i in 0..10000 { cnt += 1; pl.update(1u32); } pl.stop();
Implementations
impl ProgressLogger
[src]
pub fn builder() -> ProgressLoggerBuilder
[src]
Creates a builder to configure a new progress logger
pub fn time_to_completion(&self) -> Option<Duration>
[src]
Get the estimated time to completion, if such prediction is available
pub fn throughput(&self) -> Option<f64>
[src]
pub fn update_light<N: Into<u64>>(&mut self, cnt: N)
[src]
Try to report progress only once every million updates
pub fn update<N: Into<u64>>(&mut self, cnt: N)
[src]
Update the internal counter and report progress if the time since the last report is greater than the configured duration
pub fn stop(self)
[src]
Stops and drops the progress logger, logging the completion statement
Auto Trait Implementations
impl RefUnwindSafe for ProgressLogger
impl Send for ProgressLogger
impl Sync for ProgressLogger
impl Unpin for ProgressLogger
impl UnwindSafe for ProgressLogger
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,