pub struct Profiler {
pub enabled: bool,
pub counters: HashMap<String, Counter>,
pub span_stats: HashMap<String, SpanStats>,
pub max_history: usize,
pub frame_index: u64,
pub memory: MemoryStats,
pub gpu: GpuFrameStats,
pub fps_history: VecDeque<f64>,
pub fps: f64,
/* private fields */
}Expand description
Main CPU profiler. Not thread-safe (use per-thread instances or a Mutex).
Fields§
§enabled: bool§counters: HashMap<String, Counter>§span_stats: HashMap<String, SpanStats>§max_history: usize§frame_index: u64§memory: MemoryStats§gpu: GpuFrameStats§fps_history: VecDeque<f64>§fps: f64Implementations§
Source§impl Profiler
impl Profiler
pub fn new() -> Self
Sourcepub fn set_counter(&mut self, name: &str, value: f64)
pub fn set_counter(&mut self, name: &str, value: f64)
Set a named counter to an absolute value.
Sourcepub fn frame_begin(&mut self)
pub fn frame_begin(&mut self)
Call at the start of each frame.
Sourcepub fn frame_end(&mut self) -> FrameRecord
pub fn frame_end(&mut self) -> FrameRecord
Call at the end of each frame. Returns the completed FrameRecord.
Sourcepub fn build_flame_graph(&self, last_n_frames: usize) -> FlameNode
pub fn build_flame_graph(&self, last_n_frames: usize) -> FlameNode
Build a flame graph from the last N frames.
Sourcepub fn recent_frames(&self, n: usize) -> &[FrameRecord]
pub fn recent_frames(&self, n: usize) -> &[FrameRecord]
Get the last N frame records.
Sourcepub fn last_frame(&self) -> Option<&FrameRecord>
pub fn last_frame(&self) -> Option<&FrameRecord>
Get the last completed frame.
Sourcepub fn avg_frame_ms(&self) -> f64
pub fn avg_frame_ms(&self) -> f64
Average frame time in ms.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Profiler
impl RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnsafeUnpin for Profiler
impl UnwindSafe for Profiler
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.