Struct FrameProfiler
pub struct FrameProfiler { /* private fields */ }Expand description
The crate::app::App holds one of these behind an Option; the
headless crate::headless::FrameHarness holds another for the perf harness.
Both feed it the same way: record a pass duration, then
commit_frame once per frame.
Implementations§
§impl FrameProfiler
impl FrameProfiler
pub fn from_env() -> Option<FrameProfiler>
pub fn from_env() -> Option<FrameProfiler>
TILO_PROFILE (non-empty) turns on the in-app HUD;
TILO_PROFILE_OUT=<path> appends a per-frame dump (CSV when the path
ends in .csv, JSON-lines otherwise); either alone enables profiling.
Deliberately not gated on debug_assertions: the point of a
profiler is to measure release builds, where frame cost matters.
pub fn from_diagnostics(
diagnostics: &RunnerDiagnostics,
) -> Option<FrameProfiler>
pub fn from_diagnostics( diagnostics: &RunnerDiagnostics, ) -> Option<FrameProfiler>
The profiler diagnostics asks for, if any: its HUD flag and dump
path correspond to TILO_PROFILE and TILO_PROFILE_OUT.
pub fn for_capture() -> FrameProfiler
pub fn for_capture() -> FrameProfiler
No HUD, no dump. Used by the headless harness.
pub fn hud_enabled(&self) -> bool
pub fn record(&mut self, pass: Pass, dur: Duration)
pub fn record_since(&mut self, pass: Pass, start: Option<Instant>)
pub fn record_since(&mut self, pass: Pass, start: Option<Instant>)
Does nothing when start is None (profiling was off when the
pass began). Keeps the call sites in app.rs / headless.rs to
two lines each.
pub fn commit_frame(&mut self, total_us: u64)
pub fn commit_frame(&mut self, total_us: u64)
total_us is the live app’s measured wall time.
pub fn commit_frame_summed(&mut self)
pub fn commit_frame_summed(&mut self)
Used by the headless harness, where passes run contiguously so their sum is the frame cost.
pub fn take_capture(&mut self) -> Vec<FrameTiming>
pub fn take_capture(&mut self) -> Vec<FrameTiming>
Drains the buffer. Empty when not in capture mode.
pub fn clear_capture(&mut self)
pub fn clear_capture(&mut self)
Discard captured frames (e.g. warmup) without stopping capture.
pub fn history(&self) -> &VecDeque<FrameTiming>
pub fn history(&self) -> &VecDeque<FrameTiming>
Most recent frame last.
pub fn draw_hud(
&self,
scene: &mut Scene,
transform: Affine,
text: &mut TextRenderer,
theme: &Theme,
viewport: (f64, f64),
)
pub fn draw_hud( &self, scene: &mut Scene, transform: Affine, text: &mut TextRenderer, theme: &Theme, viewport: (f64, f64), )
Drawn in the same logical space and transform the app draws its
widgets with, so it’s crisp at any scale. viewport is the logical
(width, height). A top-right panel: a text readout above a rolling
bar graph, with the 16.6ms budget line drawn across it and
over-budget bars painted red.
Auto Trait Implementations§
impl Freeze for FrameProfiler
impl RefUnwindSafe for FrameProfiler
impl Send for FrameProfiler
impl Sync for FrameProfiler
impl Unpin for FrameProfiler
impl UnsafeUnpin for FrameProfiler
impl UnwindSafe for FrameProfiler
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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