Struct solana_measure::measure::Measure [−][src]
pub struct Measure { /* fields omitted */ }
Implementations
impl Measure
[src]
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]
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
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
impl<T> AbiExample for T
pub default fn example() -> T
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,