Struct puffin::ThreadProfiler

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

Collects profiling data for one thread

Implementations§

source§

impl ThreadProfiler

source

pub fn initialize( now_ns: fn() -> NanoSecond, reporter: fn(_: ThreadInfo, _: &[ScopeDetails], _: &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 ([internal_profile_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, internal_profile_reporter);.

source

pub fn register_function_scope( &mut self, function_name: impl Into<Cow<'static, str>>, file_path: impl Into<Cow<'static, str>>, line_nr: u32 ) -> ScopeId

Register a function scope.

source

pub fn register_named_scope( &mut self, scope_name: impl Into<Cow<'static, str>>, function_name: impl Into<Cow<'static, str>>, file_path: impl Into<Cow<'static, str>>, line_nr: u32 ) -> ScopeId

Register a named scope.

source

pub fn begin_scope(&mut self, scope_id: ScopeId, data: &str) -> usize

Marks the beginning of the scope. Returns position where to write scope size once the scope is closed.

source

pub fn end_scope(&mut self, start_offset: usize)

Marks the end of the scope. Returns the current depth.

source

pub fn call<R>(f: impl Fn(&mut Self) -> R) -> R

Do something with the thread local ThreadProfiler

Trait Implementations§

source§

impl Default for ThreadProfiler

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.