[−][src]Struct iter_progress::ProgressRecord
Every step of the underlying iterator, one of these is generated. It contains all the information of how this iterator is progresing. Use the methods to access data on it.
Methods
impl ProgressRecord
[src]
pub fn duration_since_start(&self) -> Duration
[src]
Duration since iteration started
pub fn num_done(&self) -> usize
[src]
Number of items we've generated so far. Will be 0 for the first element
let mut progressor = (0..1_000).progress(); let (state, num) = progressor.next().unwrap(); assert_eq!(state.num_done(), 1);
let mut progressor = (0..1_000).progress().skip(120); let (state, num) = progressor.next().unwrap(); assert_eq!(state.num_done(), 121);
pub fn previous_record_tm(&self) -> Option<Instant>
[src]
The Instant
for when the previous record was generated. None if there was no previous
record.
This can be useful for calculating fine-grained rates
pub fn started_iterating(&self) -> Instant
[src]
Return the time Instant
that this iterator started
pub fn rate(&self) -> f64
[src]
Number of items per second, calculated from the start
pub fn fraction(&self) -> Option<f64>
[src]
How far through the iterator as a fraction, if known.
Uses the underlying iterator's .size_hint()
method if that is an exact value, falling
back to any assumed size (set with .assume_size(...)
). Otherwise returns None
.
use iter_progress::ProgressableIter; let mut progressor = (0..1_000).progress().skip(120); let (state, num) = progressor.next().unwrap(); assert_eq!(num, 120); assert_eq!(state.fraction(), Some(0.121));
Returns None
if we cannot know, e.g. for an infinite iterator
let mut progressor = (0..).progress().skip(120); let (state, num) = progressor.next().unwrap(); assert_eq!(state.fraction(), None);
pub fn percent(&self) -> Option<f64>
[src]
Percentage progress through the iterator, if known.
use iter_progress::ProgressableIter; let mut progressor = (0..1_000).progress().skip(120); let (state, num) = progressor.next().unwrap(); assert_eq!(state.percent(), Some(12.1));
Returns None
if we cannot know, e.g. for an infinite iterator
let mut progressor = (0..).progress().skip(120); let (state, num) = progressor.next().unwrap(); assert_eq!(state.percent(), None);
pub fn print_every_n_sec<T: Display>(&self, n: f32, msg: T)
[src]
Print out msg
, but only if there has been n
seconds since last printout. (uses
print!()
, so newline not included)
pub fn do_every_n_sec<F: Fn(&Self)>(&self, n: impl Into<f32>, f: F)
[src]
Call this function, but only every n sec (as close as possible). Could be a print statement.
pub fn should_do_every_n_sec(&self, n: impl Into<f32>) -> bool
[src]
If we want to do every n
sec, should we do it now?
pub fn should_do_every_n_items(&self, n: usize) -> bool
[src]
If we want to do every n
items, should we do it now?
pub fn print_every_n_items<T: Display>(&self, n: usize, msg: T)
[src]
Print out msg
, but only if there has been n
items.
Often you want to print out a debug message every 1,000 items or so. This function does
that.
pub fn do_every_n_items<F: Fn(&Self)>(&self, n: usize, f: F)
[src]
Do thing but only every n
items.
Could be a print statement.
takes 2 arguments, n
and the function (f
) which takes a &ProgressState
. f
will only
be called every n
items that pass through the iterator.
for (state, _) in (0..150).progress() { state.do_every_n_items(5, |state| { println!("Current progress: {}%", state.percent().unwrap()); }); }
pub fn rolling_average_duration(&self) -> &Option<Duration>
[src]
Rolling average time to process each item this iterator is processing if it is recording that. None if it's not being recorded, or it's too soon to know (e.g. for the first item).
pub fn rolling_average_rate(&self) -> Option<f64>
[src]
Rolling average number of items per second this iterator is processing if it is recording that. None if it's not being recorded, or it's too soon to know (e.g. for the first item).
pub fn exp_average_duration(&self) -> &Option<Duration>
[src]
Exponential average time to process each item this iterator is processing if it is recording that. None if it's not being recorded, or it's too soon to know (e.g. for the first item).
pub fn exp_average_rate(&self) -> Option<f64>
[src]
Exponential average number of items per second this iterator is processing if it is recording that. None if it's not being recorded, or it's too soon to know (e.g. for the first item).
pub fn eta(&self) -> Option<Duration>
[src]
If the total size is know (i.e. we know the .fraction()
), calculate the estimated time
to arrival, i.e. how long before this is finished.
pub fn estimated_total_time(&self) -> Option<Duration>
[src]
If the total size is know (i.e. we know the .fraction()
), calculate how long, in total,
this iterator would run for. i.e. how long it's run plus how much longer it has left
Auto Trait Implementations
impl RefUnwindSafe for ProgressRecord
impl Send for ProgressRecord
impl Sync for ProgressRecord
impl Unpin for ProgressRecord
impl UnwindSafe for ProgressRecord
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>,