Attribute Macro perf_with_debug

Source
#[perf_with_debug]
Expand description

Wrap the method call with near_performance_metrics::stats::measure_performance_with_debug function.

This derive can be used to provide performance metrics to method calls with Actors. Currently we print performance stats per thread every minute, and we print a warning whenever a function call exceeds took more than given time limit. It should have no performance impact unless performance_stats feature is enabled. In addition to prints provided by perf, perf_with_debug prints enum variant type of the message.

This function assumes it wraps around a method with &mut self, msg: NetworkClientMessages, ctx: &mut Self::Context<Self> as arguments. There is currently a requirement that the second argument is called msg. There is an assumption that the argument called msg is an enum, which has #[derive(AsStaticStr)].

§Examples

use strum::AsStaticStr;

#[derive(AsStaticStr)]
pub enum MyMessage {
     ExampleMessage()
}

pub struct ExampleResponse {}
impl Handler<NetworkClientMessages> for ClientActor {
   type Result = ExampleResponse;

   #[perf_with_debug]
   fn handle(&mut self, msg: NetworkClientMessages, ctx: &mut Self::Context<Self>) -> Self::Result {
       ExampleResponse{}
   }
}