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>

source

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.

source

pub fn start<T: AsRef<str>>(&mut self, msg: T)

Start the logger, displaying the given message.

source

pub fn display_memory(self) -> Self

Chainable setter enabling memory display.

source

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.

source

pub fn update(&mut self)

Increase the count and check whether it is time to log.

source

pub fn update_with_count(&mut self, count: usize)

Set the count and check whether it is time to log.

source

pub fn light_update(&mut self)

Increase the count and, once every LIGHT_UPDATE_MASK + 1 calls, check whether it is time to log.

source

pub fn update_and_display(&mut self)

Increase the count and force a log.

source

pub fn stop(&mut self)

Stop the logger, fixing the final time.

source

pub fn done(&mut self)

Stop the logger, print Completed., and display the final stats. The number of expected updates will be cleared.

source

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.
source

pub fn elapsed(&self) -> Option<Duration>

Return the elapsed time since the logger was started, or None if the logger has not been started.

Trait Implementations§

source§

impl<'a> Default for ProgressLogger<'a>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'a> Display for ProgressLogger<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for ProgressLogger<'a>

§

impl<'a> Send for ProgressLogger<'a>

§

impl<'a> Sync for ProgressLogger<'a>

§

impl<'a> Unpin for ProgressLogger<'a>

§

impl<'a> UnwindSafe for ProgressLogger<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.