Struct puffin::GlobalProfiler

source ·
pub struct GlobalProfiler { /* private fields */ }
Expand description

Singleton. Collects profiling data from multiple threads and passes them on to different FrameSinks.

Implementations§

source§

impl GlobalProfiler

source

pub fn lock() -> MutexGuard<'static, Self>

Access to the global profiler singleton.

source

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.

source

pub fn add_frame(&mut self, new_frame: Arc<FrameData>)

Manually add frame data.

source

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.

source

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.

source

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.

source

pub fn remove_sink(&mut self, id: FrameSinkId) -> Option<FrameSink>

Removes a sink from the global profiler.

source

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.

Trait Implementations§

source§

impl Default for GlobalProfiler

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.