Struct solana_measure::measure::Measure [−][src]
pub struct Measure { /* fields omitted */ }
Implementations
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 UnwindSafe for Measure