Struct abstutil::time::Timer

source ·
pub struct Timer<'a> {
    results: Vec<String>,
    stack: Vec<StackEntry>,
    outermost_name: String,
    sink: Option<Box<dyn TimerSink + 'a>>,
}
Expand description

Hierarchial magic

Fields§

§results: Vec<String>§stack: Vec<StackEntry>§outermost_name: String§sink: Option<Box<dyn TimerSink + 'a>>

Implementations§

source§

impl<'a> Timer<'a>

source

pub fn new<S: Into<String>>(raw_name: S) -> Timer<'a>

source

pub fn new_with_sink(name: &str, sink: Box<dyn TimerSink + 'a>) -> Timer<'a>

source

pub fn throwaway() -> Timer<'a>

source

fn temporary_println(&mut self, line: String)

source

pub fn done(self)

Used to end the scope of a timer early.

source

pub fn start<S: Into<String>>(&mut self, raw_name: S)

source

pub fn stop<S: Into<String>>(&mut self, raw_name: S)

source

pub fn start_iter<S: Into<String>>(&mut self, raw_name: S, total_items: usize)

source

pub fn next(&mut self)

source

pub fn cancel_iter_early(&mut self)

source

pub fn add_result(&mut self, elapsed: f64, line: String)

source

pub fn parallelize<I, O, F>( &mut self, timer_name: &str, requests: Vec<I>, cb: F ) -> Vec<O>
where I: Send, O: Send, F: Send + Clone + Copy + Fn(I) -> O,

Execute the callback over all requests, using all CPUs available. The order of the result is deterministic and matches the input.

source

pub fn parallelize_polite<I, O, F>( &mut self, timer_name: &str, requests: Vec<I>, cb: F ) -> Vec<O>
where I: Send, O: Send, F: Send + Clone + Copy + Fn(I) -> O,

Like parallelize, but leave one CPU free, to avoid thrashing the user’s system.

source

fn inner_parallelize<I, O, F>( &mut self, timer_name: &str, requests: Vec<I>, cb: F, num_cpus: u32 ) -> Vec<O>
where I: Send, O: Send, F: Send + Clone + Copy + Fn(I) -> O,

source

pub fn retain_parallelized<K, V, F>( &mut self, timer_name: &str, input: BTreeMap<K, V>, keep: F ) -> BTreeMap<K, V>
where K: Send + Ord, V: Send, F: Send + Sync + Clone + Copy + Fn(&V) -> bool,

Like BTreeMap::retain, but parallelized

source

pub fn read_file(&mut self, path: &str) -> Result<()>

Then the caller passes this in as a reader

Trait Implementations§

source§

impl<'a> Drop for Timer<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a> Read for Timer<'a>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Read all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Read all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Read the exact number of bytes required to fill buf. Read more
source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Timer<'a>

§

impl<'a> !Send for Timer<'a>

§

impl<'a> !Sync for Timer<'a>

§

impl<'a> Unpin for Timer<'a>

§

impl<'a> !UnwindSafe for Timer<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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<R> TermRead for R
where R: Read + TermReadEventsAndRaw,

§

fn events(self) -> Events<R>

An iterator over input events.
§

fn keys(self) -> Keys<R>

An iterator over key inputs.
§

fn read_line(&mut self) -> Result<Option<String>, Error>

Read a line. Read more
§

fn read_passwd<W>(&mut self, writer: &mut W) -> Result<Option<String>, Error>
where W: Write,

Read a password. Read more
§

impl<R> TermReadEventsAndRaw for R
where R: Read,

§

fn events_and_raw(self) -> EventsAndRaw<R>

An iterator over input events and the bytes that define them.
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.