pub struct EventContext {
pub frame_id: Option<FrameId>,
pub logical_window_id: Option<BenchWindowId>,
pub surface_id: Option<BenchSurfaceId>,
pub presentation_generation: Option<u64>,
pub cause_event_ids: Vec<EventId>,
pub sample_phase: SamplePhase,
}Expand description
Correlation attached to a recorded event.
All identifiers are optional. presentation_generation should be present
with surface_id; builders set the pair atomically. An empty cause list
means no predecessor was declared. Samples default to measured.
§Examples
use ailloli_ui_bench::{EventContext, FrameId, SamplePhase};
let context = EventContext::default()
.with_frame(FrameId::new(3))
.with_sample_phase(SamplePhase::Warmup);
assert_eq!(context.frame_id, Some(FrameId::new(3)));
assert_eq!(context.sample_phase, SamplePhase::Warmup);Fields§
§frame_id: Option<FrameId>Frame containing the event, or None for run-level events.
logical_window_id: Option<BenchWindowId>Logical host window associated with the event.
surface_id: Option<BenchSurfaceId>Logical presentation surface associated with the event.
presentation_generation: Option<u64>Surface generation paired with Self::surface_id.
cause_event_ids: Vec<EventId>Earlier event IDs declared as causal predecessors.
sample_phase: SamplePhaseWhether a numeric sample is warmup-only or measured.
Implementations§
Source§impl EventContext
impl EventContext
Sourcepub fn with_frame(self, frame_id: FrameId) -> Self
pub fn with_frame(self, frame_id: FrameId) -> Self
Associates the event with a frame.
§Examples
use ailloli_ui_bench::{EventContext, FrameId};
let context = EventContext::default().with_frame(FrameId::new(4));
assert_eq!(context.frame_id, Some(FrameId::new(4)));Sourcepub fn with_window(self, window_id: BenchWindowId) -> Self
pub fn with_window(self, window_id: BenchWindowId) -> Self
Associates the event with a logical window.
§Examples
use ailloli_ui_bench::{BenchWindowId, EventContext};
let context = EventContext::default().with_window(BenchWindowId::new("main"));
assert_eq!(context.logical_window_id.unwrap().as_str(), "main");Sourcepub fn with_surface(
self,
surface_id: BenchSurfaceId,
presentation_generation: u64,
) -> Self
pub fn with_surface( self, surface_id: BenchSurfaceId, presentation_generation: u64, ) -> Self
Associates the event with a logical surface and presentation generation.
§Examples
use ailloli_ui_bench::{BenchSurfaceId, EventContext};
let context = EventContext::default().with_surface(BenchSurfaceId::new("s0"), 2);
assert_eq!(context.presentation_generation, Some(2));Sourcepub fn caused_by(self, event_id: EventId) -> Self
pub fn caused_by(self, event_id: EventId) -> Self
Adds a causal predecessor.
Repeated IDs are retained in insertion order.
§Examples
use ailloli_ui_bench::{EventContext, EventId};
let context = EventContext::default().caused_by(EventId::new(8));
assert_eq!(context.cause_event_ids, vec![EventId::new(8)]);Sourcepub fn with_sample_phase(self, sample_phase: SamplePhase) -> Self
pub fn with_sample_phase(self, sample_phase: SamplePhase) -> Self
Marks whether this event is a warmup or measured sample.
§Examples
use ailloli_ui_bench::{EventContext, SamplePhase};
let context = EventContext::default().with_sample_phase(SamplePhase::Warmup);
assert_eq!(context.sample_phase, SamplePhase::Warmup);Trait Implementations§
Source§impl Clone for EventContext
impl Clone for EventContext
Source§fn clone(&self) -> EventContext
fn clone(&self) -> EventContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more