macro_rules! duration {
($category:expr, $name:expr $(, $key:expr => $val:expr)* $(,)?) => { ... };
}
Expand description
Convenience macro for the duration
function that can be used to trace
the duration of a scope. If you need finer grained control over when a
duration starts and stops, see duration_begin
and duration_end
.
Example:
{
duration!(c"foo", c"bar", "x" => 5, "y" => 10);
...
...
// event will be recorded on drop.
}
is equivalent to
{
let mut args;
let _scope = {
static CACHE: trace_site_t = trace_site_t::new(0);
if let Some(_context) = TraceCategoryContext::acquire_cached(c"foo", &CACHE) {
args = [ArgValue::of("x", 5), ArgValue::of("y", 10)];
Some($crate::duration(c"foo", c"bar", &args))
} else {
None
}
};
...
...
// event will be recorded on drop.
}