Struct EventContext

Source
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: SamplePhase

Whether a numeric sample is warmup-only or measured.

Implementations§

Source§

impl EventContext

Source

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)));
Source

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");
Source

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));
Source

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)]);
Source

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

Source§

fn clone(&self) -> EventContext

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventContext

Source§

fn default() -> EventContext

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for EventContext

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for EventContext

Source§

fn eq(&self, other: &EventContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EventContext

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for EventContext

Source§

impl StructuralPartialEq for EventContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,