Sometimes I find myself wishing there was a way to only instrument a piece of code if some condition is met, to reduce overhead:
fn do_stuff(n: usize) {
puffin::profile_scope_if!(10_000 < n, "processing lots of data");
for i in 0..n {
…
}
}
If do_stuff is called once with a big n, we get a profile scope.
If do_stuff is called a million times with a small n, we don't pay the overhead of the profiling.
Sometimes I find myself wishing there was a way to only instrument a piece of code if some condition is met, to reduce overhead:
If
do_stuff
is called once with a bign
, we get a profile scope. Ifdo_stuff
is called a million times with a smalln
, we don't pay the overhead of the profiling.