#[non_exhaustive]pub struct Metrics { /* private fields */ }Expand description
Aggregated simulation metrics, updated each tick from events.
Games query this via sim.metrics() for HUD display, scoring,
or scenario evaluation.
Implementations§
Source§impl Metrics
impl Metrics
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new Metrics with default throughput window (3600 ticks)
and default wait-sample capacity (10 000).
Sourcepub const fn with_throughput_window(self, window_ticks: u64) -> Self
pub const fn with_throughput_window(self, window_ticks: u64) -> Self
Set the throughput window size (builder pattern).
Sourcepub fn with_wait_sample_capacity(self, capacity: usize) -> Self
pub fn with_wait_sample_capacity(self, capacity: usize) -> Self
Set the wait-sample ring buffer capacity (builder pattern). 0
disables wait sampling entirely; percentile_wait_time
will return 0 once the buffer is empty.
Shrinking below the current sample count truncates from the front (oldest samples evicted first) so the retained window always represents the most recent waits.
Sourcepub const fn avg_wait_time(&self) -> f64
pub const fn avg_wait_time(&self) -> f64
Average wait time in ticks (spawn to board).
Sourcepub const fn avg_ride_time(&self) -> f64
pub const fn avg_ride_time(&self) -> f64
Average ride time in ticks (board to exit).
Sourcepub const fn max_wait_time(&self) -> u64
pub const fn max_wait_time(&self) -> u64
Maximum wait time observed (ticks).
Sourcepub fn p95_wait_time(&self) -> u64
pub fn p95_wait_time(&self) -> u64
95th-percentile wait time over the last wait_sample_capacity
boardings (ticks). Shorthand for percentile_wait_time(95.0).
Returns 0 when no samples have been recorded.
CIBSE and community-benchmark traffic studies score against
percentiles rather than the (avg, max) pair alone — max is
dominated by rare outliers, avg hides the tail.
Sourcepub fn percentile_wait_time(&self, p: f64) -> u64
pub fn percentile_wait_time(&self, p: f64) -> u64
Wait-time percentile over the retained sample window (ticks).
Uses the “nearest-rank” method: ceil(p/100 * n)-th smallest
sample, clamped into 0..n. p = 0.0 returns the minimum,
p = 100.0 returns the maximum. Returns 0 when the buffer
is empty.
§Panics
Panics if p is NaN or outside [0.0, 100.0].
Sourcepub fn wait_sample_count(&self) -> usize
pub fn wait_sample_count(&self) -> usize
Number of wait samples currently retained in the ring buffer. Useful for tests and HUDs that want to display “5 000 samples over last window” style diagnostics.
Sourcepub const fn throughput(&self) -> u64
pub const fn throughput(&self) -> u64
Riders delivered in the current throughput window.
Sourcepub const fn total_delivered(&self) -> u64
pub const fn total_delivered(&self) -> u64
Riders delivered total.
Sourcepub const fn total_abandoned(&self) -> u64
pub const fn total_abandoned(&self) -> u64
Riders who abandoned.
Sourcepub const fn total_spawned(&self) -> u64
pub const fn total_spawned(&self) -> u64
Total riders spawned.
Sourcepub const fn abandonment_rate(&self) -> f64
pub const fn abandonment_rate(&self) -> f64
Abandonment rate (0.0 - 1.0).
Sourcepub const fn total_distance(&self) -> f64
pub const fn total_distance(&self) -> f64
Total distance traveled by all elevators.
Sourcepub const fn utilization_by_group(&self) -> &BTreeMap<String, f64>
pub const fn utilization_by_group(&self) -> &BTreeMap<String, f64>
Per-group instantaneous elevator utilization (fraction of elevators moving).
Sourcepub const fn reposition_distance(&self) -> f64
pub const fn reposition_distance(&self) -> f64
Total distance traveled by elevators while repositioning.
Sourcepub const fn total_moves(&self) -> u64
pub const fn total_moves(&self) -> u64
Total rounded-floor transitions across all elevators (passing-floor crossings plus arrivals).
Sourcepub const fn total_settled(&self) -> u64
pub const fn total_settled(&self) -> u64
Total riders settled as residents.
Sourcepub const fn total_rerouted(&self) -> u64
pub const fn total_rerouted(&self) -> u64
Total riders rerouted from resident phase.
Sourcepub const fn throughput_window_ticks(&self) -> u64
pub const fn throughput_window_ticks(&self) -> u64
Window size for throughput calculation (ticks).
Sourcepub const fn total_energy_consumed(&self) -> f64
pub const fn total_energy_consumed(&self) -> f64
Total energy consumed by all elevators (requires energy feature).
Sourcepub const fn total_energy_regenerated(&self) -> f64
pub const fn total_energy_regenerated(&self) -> f64
Total energy regenerated by all elevators (requires energy feature).
Sourcepub const fn net_energy(&self) -> f64
pub const fn net_energy(&self) -> f64
Net energy: consumed minus regenerated (requires energy feature).
Sourcepub fn avg_utilization(&self) -> f64
pub fn avg_utilization(&self) -> f64
Overall utilization: average across all groups.
Trait Implementations§
Source§impl Default for Metrics
impl Default for Metrics
Source§fn default() -> Self
fn default() -> Self
Delegates to Metrics::new so #[derive(Default)]-on-holders and
direct Metrics::default() callers get the same 3600-tick throughput
window and 10 000-sample wait buffer that new() wires up. Without
this, the derived Default would zero every field — silently
disabling p95_wait_time sampling and collapsing the throughput
window to an empty range (greptile review of #347).