Expand description
Usage:
fn main() {
puffin::set_scopes_on(true); // you may want to control this with a flag
// game loop
loop {
puffin::GlobalProfiler::lock().new_frame();
{
puffin::profile_scope!("slow_code");
slow_code();
}
}
}
Re-exports§
pub use utils::clean_function_name;
pub use utils::short_file_name;
pub use utils::type_name_of;
Macros§
- current_
function_ name - Returns the name of the calling function without a long module path prefix.
- profile_
function - Automatically name the profiling scope based on function name.
- profile_
function_ if - Conditionally profile the current function.
- profile_
scope - Profile the current scope with the given name (unique in the parent scope).
- profile_
scope_ custom - Profile the current scope with the given name (unique in the parent scope).
- profile_
scope_ custom_ if - Like
profile_scope_custom
, but only conditionally profiles the scope. - profile_
scope_ if - Like
profile_scope
, but only conditionally profiles the scope.
Structs§
- Frame
Data - One frame worth of profile data, collected from many sources.
- Frame
Meta - Meta-information about a frame.
- Frame
Sink Id - Identifies a specific
FrameSink
when added toGlobalProfiler
. - Frame
Stats - Collect statistics for maintained frames
- Frame
View - A view of recent and slowest frames, used by GUIs.
- Global
Frame View - Automatically connects to
crate::GlobalProfiler
. - Global
Profiler - Singleton. Collects profiling data from multiple threads
and passes them on to different
FrameSink
s. - Merge
Scope - A scope that has been merged from many different sources
- Profiler
Scope - Created by the
puffin::profile*!(...)
macros. - Reader
- TODO: Improve encapsulation.
Parses a
Stream
of profiler data. - Scope
- TODO: Improve encapsulation. Used when parsing a Stream.
- Scope
Collection - A collection of scope details containing more information about a recorded profile scope.
- Scope
Details - Detailed information about a scope.
- ScopeId
- A unique id for each scope and
ScopeDetails
. - Scope
Record - TODO: Improve encapsulation. Used when parsing a Stream.
- Stream
- TODO: Improve encapsulation. Stream of profiling events from one thread.
- Stream
Info - TODO: Improve encapsulation.
A
Stream
plus some info about it. - Stream
Info Ref - TODO: Improve encapsulation.
A reference to the contents of a
StreamInfo
. - Thread
Info - Used to identify one source of profiling data.
- Thread
Profiler - Collects profiling data for one thread
- Unpacked
Frame Data - One frame worth of profile data, collected from many sources.
Enums§
- Error
- TODO: Improve encapsulation.
Errors that can happen when parsing a
Stream
of profile data. - Scope
Type - Scopes are identified by user-provided name while functions are identified by the function name.
Functions§
- are_
scopes_ on - Are the profiler scope macros turned on?
This is
false
by default. - internal_
profile_ reporter - Report a stream of profile data from a thread to the
GlobalProfiler
singleton. This is used for internal purposes only - merge_
scopes_ for_ thread - For the given thread, merge all scopes with the same id+data path.
- now_ns
- Returns a high-precision, monotonically increasing nanosecond count since unix epoch.
- select_
slowest - Select the slowest frames, up to a certain count.
- set_
scopes_ on - Turn on/off the profiler macros (
profile_function
,profile_scope
etc). When off, these calls take only 1-2 ns to call (100x faster). This isfalse
by default. - shorten_
rust_ function_ name - Shorten a rust function name by removing the leading parts of module paths.
Type Aliases§
- Frame
Index - An incremental monolithic counter to identify frames.
- Frame
Sink - Add these to
GlobalProfiler
withGlobalProfiler::add_sink()
. - Nano
Second - All times are expressed as integer nanoseconds since some event.
- Result
- TODO: Improve encapsulation. Custom puffin result type.