Instrument your Rust code with Puffin macros
mainTo profile your code, use the puffin::profile_function!() macro to profile an entire function, or puffin::profile_scope!(name, args) to profile a specific block of code with a custom name and optional arguments.
Note that these macros write to a thread-local data stream. The scopes are lightweight (approx. 50-200 ns), but you must explicitly enable the profiler using puffin::set_scopes_on(true); before any data can be captured. When the profiler is disabled, the overhead is minimal (~1 ns).
fn my_function() {
puffin::profile_function!();
...
if ... {
puffin::profile_scope!("load_image", image_name);
...
}
}