Struct solana_measure::measure::Measure[][src]

pub struct Measure { /* fields omitted */ }

Implementations

impl Measure[src]

pub fn start(name: &'static str) -> Self[src]

pub fn stop(&mut self)[src]

pub fn as_ns(&self) -> u64[src]

pub fn as_us(&self) -> u64[src]

pub fn as_ms(&self) -> u64[src]

pub fn as_s(&self) -> f32[src]

pub fn this<T, R, F: FnOnce(T) -> R>(
    func: F,
    args: T,
    name: &'static str
) -> (R, Self)
[src]

Measure this function

Use Measure::this() when you have a function that you want to measure. this() will start a new Measure, call your function, stop the measure, then return the Measure object along with your function’s return value.

If your function takes more than one parameter, you will need to wrap your function in a closure, and wrap the arguments in a tuple. The same thing applies to methods. See the tests for more details.

Examples

// Call a function with a single argument
let (result, measure) = Measure::this(my_function, fizz, "my_func");
// Call a function with multiple arguments
let (result, measure) = Measure::this(|(arg1, arg2)| my_function(arg1, arg2), ("abc", 123), "my_func");
/// Call a method
struct Foo { ...  }
impl Foo { fn bar(&self, some_arg: i32) { ... } }

let foo = Foo { };
let (result, measure) = Measure::this(|this, arg| Foo::bar(&this, arg), (&foo, arg), "bar");

Trait Implementations

impl Display for Measure[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl RefUnwindSafe for Measure

impl Send for Measure

impl Sync for Measure

impl Unpin for Measure

impl UnwindSafe for Measure

Blanket Implementations

impl<T> AbiExample for T

pub default fn example() -> T

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V