[][src]Macro metrics_facade::timing

macro_rules! timing {
    ($name:tt, $value:expr) => { ... };
    ($name:tt, $start:expr, $end:expr) => { ... };
}

Records a timing.

Functionally equivalent to calling Recorder::record_histogram.

Examples

fn handle_request() {
    let start = Instant::now();
    process();
    let end = Instant::now();

    // We can pass instances of `Instant` directly:
    timing!("performance.request_processed", start, end);

    // Or we can pass just the delta:
    let delta = end - start;
    timing!("performance.request_processed", delta);

    // And we can even pass unsigned values, both for the start/end notation:
    let start: u64 = 100;
    let end: u64 = 200;
    timing!("performance.request_processed", start, end);

    // And the delta notation:
    let delta: u64 = end - start;
    timing!("performance.request_processed", delta);
}