Struct puffin::GlobalProfiler
source · pub struct GlobalProfiler { /* private fields */ }
Expand description
Singleton. Collects profiling data from multiple threads
and passes them on to different FrameSink
s.
Implementations§
source§impl GlobalProfiler
impl GlobalProfiler
sourcepub fn lock() -> MutexGuard<'static, Self>
pub fn lock() -> MutexGuard<'static, Self>
Access to the global profiler singleton.
sourcepub fn new_frame(&mut self)
pub fn new_frame(&mut self)
You need to call this once at the start of every frame.
It is fine to call this from within a profile scope.
This takes all completed profiling scopes from all threads, and sends it to the sinks.
sourcepub fn register_user_scopes(&mut self, scopes: &[ScopeDetails]) -> Vec<ScopeId>
pub fn register_user_scopes(&mut self, scopes: &[ScopeDetails]) -> Vec<ScopeId>
Inserts user scopes into puffin. Returns the scope id for every inserted scope in the same order as input slice.
Scopes details should only be registered once for each scope and need be inserted before being reported to puffin.
This function is relevant when you’re registering measurement not performed using the puffin profiler macros.
Scope id is always supposed to be None
as it will be set by puffin.
sourcepub fn report_user_scopes(
&mut self,
info: ThreadInfo,
stream_scope_times: &StreamInfoRef<'_>
)
pub fn report_user_scopes( &mut self, info: ThreadInfo, stream_scope_times: &StreamInfoRef<'_> )
Reports user scopes to puffin profiler.
Every scope reported should first be registered by Self::register_user_scopes
.
sourcepub fn add_sink(&mut self, sink: FrameSink) -> FrameSinkId
pub fn add_sink(&mut self, sink: FrameSink) -> FrameSinkId
Tells GlobalProfiler
to call this function with each new finished frame.
The returned FrameSinkId
can be used to remove the sink with Self::remove_sink()
.
If the sink is registered later in the application make sure to call Self::emit_scope_snapshot()
to send a snapshot of all scopes.
sourcepub fn remove_sink(&mut self, id: FrameSinkId) -> Option<FrameSink>
pub fn remove_sink(&mut self, id: FrameSinkId) -> Option<FrameSink>
Removes a sink from the global profiler.
sourcepub fn emit_scope_snapshot(&mut self)
pub fn emit_scope_snapshot(&mut self)
Sends a snapshot of all scopes to all sinks via the frame data. This is useful for if a sink is initialized after scopes are registered.