darkwing

Macro measure_time

source
macro_rules! measure_time {
    ($name:expr, $body:expr) => { ... };
}
Expand description

Measures the execution time of a code block and records it as a histogram metric.

§Arguments

  • $name - The name of the metric to record the timing under
  • $body - The code block or expression to measure

§Example

let result = measure_time!("my_operation", db.fetch_user(id));

Or:

let result = measure_time!("my_operation", {
     db.fetch_user(id)
});

This will record the execution time of the code block under the metric name darkwing_time_my_operation_duration_seconds as a histogram in seconds.