Struct puffin::ThreadProfiler
source · pub struct ThreadProfiler { /* private fields */ }
Expand description
Collects profiling data for one thread
Implementations§
source§impl ThreadProfiler
impl ThreadProfiler
sourcepub fn initialize(
now_ns: fn() -> NanoSecond,
reporter: fn(_: ThreadInfo, _: &StreamInfoRef<'_>)
)
pub fn initialize(
now_ns: fn() -> NanoSecond,
reporter: fn(_: ThreadInfo, _: &StreamInfoRef<'_>)
)
Explicit initialize with custom callbacks.
If not called, each thread will use the default nanosecond source (now_ns()
)
and report scopes to the global profiler (global_reporter()
).
For instance, when compiling for WASM the default timing function (now_ns()
) won’t work,
so you’ll want to call puffin::ThreadProfiler::initialize(my_timing_function, puffin::global_reporter);
.
sourcepub fn begin_scope(&mut self, id: &str, location: &str, data: &str) -> usize
pub fn begin_scope(&mut self, id: &str, location: &str, data: &str) -> usize
Returns position where to write scope size once the scope is closed.
pub fn end_scope(&mut self, start_offset: usize)
sourcepub fn call<R>(f: impl Fn(&mut Self) -> R) -> R
pub fn call<R>(f: impl Fn(&mut Self) -> R) -> R
Do something with the thread local ThreadProfiler