#[non_exhaustive]pub struct TgsCacheStats {
pub hits: u64,
pub misses: u64,
}Expand description
Snapshot of SolverBackend::Tgs’s per-frame warm-start impulse cache
effectiveness, returned by PhysicsWorld::tgs_cache_stats.
Mirrors crate::solver_tgs::ImpulseCacheStats (which stays
crate-internal along with the rest of the solver_tgs family, see
SolverBackend’s module doc) so a host can read warm-start
diagnostics without depending on any pub(crate) type.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.hits: u64Number of contacts whose previous-tick impulse was found in the cache (a successful warm start).
misses: u64Number of contacts not found in the cache (new contact, or one
whose entry was evicted by PhysicsWorld::step’s per-tick
internal ImpulseCache::sweep call).
Implementations§
Source§impl TgsCacheStats
impl TgsCacheStats
Sourcepub fn new(hits: u64, misses: u64) -> Self
pub fn new(hits: u64, misses: u64) -> Self
Constructs from raw hit/miss counts. Prefer
PhysicsWorld::tgs_cache_stats in production; this exists so
test/bench code can construct a specific ratio directly —
#[non_exhaustive] blocks the struct-literal syntax outside this
crate.
Sourcepub fn hit_rate(&self) -> f64
pub fn hit_rate(&self) -> f64
Ratio in [0.0, 1.0]. Returns 0.0 when hits + misses == 0
(no lookups performed yet). Delegates to the internal
ImpulseCacheStats::hit_rate (the same hits / (hits + misses)
formula) rather than recomputing it here, so this public wrapper
has a real dependency on the internal type instead of merely
duplicating its arithmetic.
Trait Implementations§
Source§impl Clone for TgsCacheStats
impl Clone for TgsCacheStats
impl Copy for TgsCacheStats
Source§impl Debug for TgsCacheStats
impl Debug for TgsCacheStats
Source§impl Default for TgsCacheStats
impl Default for TgsCacheStats
impl Eq for TgsCacheStats
Source§impl PartialEq for TgsCacheStats
impl PartialEq for TgsCacheStats
impl StructuralPartialEq for TgsCacheStats
Auto Trait Implementations§
impl Freeze for TgsCacheStats
impl RefUnwindSafe for TgsCacheStats
impl Send for TgsCacheStats
impl Sync for TgsCacheStats
impl Unpin for TgsCacheStats
impl UnsafeUnpin for TgsCacheStats
impl UnwindSafe for TgsCacheStats
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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