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, _: &[ScopeDetails], _: &StreamInfoRef<'_>),
)
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 (crate::now_ns
)
and report scopes to the global profiler (internal_profile_reporter
).
For instance, when compiling for WASM the default timing function (crate::now_ns
) won’t work,
so you’ll want to call puffin::ThreadProfiler::initialize(my_timing_function, internal_profile_reporter);
.
sourcepub fn register_function_scope(
&mut self,
function_name: impl Into<Cow<'static, str>>,
file_path: impl Into<Cow<'static, str>>,
line_nr: u32,
) -> ScopeId
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.
sourcepub 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
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.
sourcepub fn begin_scope(&mut self, scope_id: ScopeId, data: &str) -> usize
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.
sourcepub fn end_scope(&mut self, start_offset: usize)
pub fn end_scope(&mut self, start_offset: usize)
Marks the end of the scope. Returns the current depth.
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
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThreadProfiler
impl RefUnwindSafe for ThreadProfiler
impl Send for ThreadProfiler
impl Sync for ThreadProfiler
impl Unpin for ThreadProfiler
impl UnwindSafe for ThreadProfiler
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more