Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::ecs::details::QueryCacheStats Struct Reference

Statistics for query cache performance. More...

#include <query_cache.hpp>

Public Member Functions

 QueryCacheStats () noexcept=default
 
 QueryCacheStats (const QueryCacheStats &other)
 
 QueryCacheStats (QueryCacheStats &&other) noexcept
 
 ~QueryCacheStats () noexcept=default
 
QueryCacheStatsoperator= (const QueryCacheStats &other)
 
QueryCacheStatsoperator= (QueryCacheStats &&other) noexcept
 
void Reset () noexcept
 
double HitRate () const noexcept
 

Public Attributes

std::atomic< size_thit_count {0}
 Number of cache hits.
 
std::atomic< size_tmiss_count {0}
 Number of cache misses.
 
std::atomic< size_tinvalidation_count {0}
 Number of cache invalidations.
 
std::atomic< size_ttotal_queries {0}
 Total number of queries executed.
 
std::atomic< size_tarchetype_changes {0}
 Number of archetype structural changes.
 
std::atomic< size_tpartial_invalidations {0}
 Number of partial (component-specific) invalidations.
 

Detailed Description

Statistics for query cache performance.

Tracks cache effectiveness metrics including hits, misses, and invalidations.

Note
Thread-safe.

Definition at line 104 of file query_cache.hpp.

Constructor & Destructor Documentation

◆ QueryCacheStats() [1/3]

helios::ecs::details::QueryCacheStats::QueryCacheStats ( )
defaultnoexcept

◆ QueryCacheStats() [2/3]

helios::ecs::details::QueryCacheStats::QueryCacheStats ( const QueryCacheStats other)
inline

Definition at line 125 of file query_cache.hpp.

126 : hit_count(other.hit_count.load(std::memory_order_relaxed)),
127 miss_count(other.miss_count.load(std::memory_order_relaxed)),
128 invalidation_count(other.invalidation_count.load(std::memory_order_relaxed)),
129 total_queries(other.total_queries.load(std::memory_order_relaxed)),
130 archetype_changes(other.archetype_changes.load(std::memory_order_relaxed)),
131 partial_invalidations(other.partial_invalidations.load(std::memory_order_relaxed)) {}
std::atomic< size_t > archetype_changes
Number of archetype structural changes.
std::atomic< size_t > miss_count
Number of cache misses.
std::atomic< size_t > total_queries
Total number of queries executed.
std::atomic< size_t > invalidation_count
Number of cache invalidations.
std::atomic< size_t > partial_invalidations
Number of partial (component-specific) invalidations.
std::atomic< size_t > hit_count
Number of cache hits.

◆ QueryCacheStats() [3/3]

helios::ecs::details::QueryCacheStats::QueryCacheStats ( QueryCacheStats &&  other)
inlinenoexcept

Definition at line 133 of file query_cache.hpp.

134 : hit_count(other.hit_count.load(std::memory_order_relaxed)),
135 miss_count(other.miss_count.load(std::memory_order_relaxed)),
136 invalidation_count(other.invalidation_count.load(std::memory_order_relaxed)),
137 total_queries(other.total_queries.load(std::memory_order_relaxed)),
138 archetype_changes(other.archetype_changes.load(std::memory_order_relaxed)),
139 partial_invalidations(other.partial_invalidations.load(std::memory_order_relaxed)) {}

◆ ~QueryCacheStats()

helios::ecs::details::QueryCacheStats::~QueryCacheStats ( )
defaultnoexcept

Member Function Documentation

◆ HitRate()

double helios::ecs::details::QueryCacheStats::HitRate ( ) const
inlinenoexcept

Definition at line 180 of file query_cache.hpp.

180 {
181 const size_t total = total_queries.load(std::memory_order_relaxed);
182 if (total == 0) [[unlikely]] {
183 return 0.0;
184 }
185
186 const size_t hits = hit_count.load(std::memory_order_relaxed);
187 return static_cast<double>(hits) / static_cast<double>(total);
188}
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ operator=() [1/2]

QueryCacheStats & helios::ecs::details::QueryCacheStats::operator= ( const QueryCacheStats other)
inline

Definition at line 141 of file query_cache.hpp.

141 {
142 if (this == &other) [[unlikely]] {
143 return *this;
144 }
145
146 hit_count.store(other.hit_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
147 miss_count.store(other.miss_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
148 invalidation_count.store(other.invalidation_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
149 total_queries.store(other.total_queries.load(std::memory_order_relaxed), std::memory_order_relaxed);
150 archetype_changes.store(other.archetype_changes.load(std::memory_order_relaxed), std::memory_order_relaxed);
151 partial_invalidations.store(other.partial_invalidations.load(std::memory_order_relaxed), std::memory_order_relaxed);
152
153 return *this;
154}

◆ operator=() [2/2]

QueryCacheStats & helios::ecs::details::QueryCacheStats::operator= ( QueryCacheStats &&  other)
inlinenoexcept

Definition at line 156 of file query_cache.hpp.

156 {
157 if (this == &other) [[unlikely]] {
158 return *this;
159 }
160
161 hit_count.store(other.hit_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
162 miss_count.store(other.miss_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
163 invalidation_count.store(other.invalidation_count.load(std::memory_order_relaxed), std::memory_order_relaxed);
164 total_queries.store(other.total_queries.load(std::memory_order_relaxed), std::memory_order_relaxed);
165 archetype_changes.store(other.archetype_changes.load(std::memory_order_relaxed), std::memory_order_relaxed);
166 partial_invalidations.store(other.partial_invalidations.load(std::memory_order_relaxed), std::memory_order_relaxed);
167
168 return *this;
169}

◆ Reset()

void helios::ecs::details::QueryCacheStats::Reset ( )
inlinenoexcept

Definition at line 171 of file query_cache.hpp.

171 {
172 hit_count.store(0, std::memory_order_relaxed);
173 miss_count.store(0, std::memory_order_relaxed);
174 invalidation_count.store(0, std::memory_order_relaxed);
175 total_queries.store(0, std::memory_order_relaxed);
176 archetype_changes.store(0, std::memory_order_relaxed);
177 partial_invalidations.store(0, std::memory_order_relaxed);
178}

Member Data Documentation

◆ archetype_changes

std::atomic<size_t> helios::ecs::details::QueryCacheStats::archetype_changes {0}

Number of archetype structural changes.

Definition at line 109 of file query_cache.hpp.

109{0}; ///< Number of archetype structural changes

◆ hit_count

std::atomic<size_t> helios::ecs::details::QueryCacheStats::hit_count {0}

Number of cache hits.

Definition at line 105 of file query_cache.hpp.

105{0}; ///< Number of cache hits

◆ invalidation_count

std::atomic<size_t> helios::ecs::details::QueryCacheStats::invalidation_count {0}

Number of cache invalidations.

Definition at line 107 of file query_cache.hpp.

107{0}; ///< Number of cache invalidations

◆ miss_count

std::atomic<size_t> helios::ecs::details::QueryCacheStats::miss_count {0}

Number of cache misses.

Definition at line 106 of file query_cache.hpp.

106{0}; ///< Number of cache misses

◆ partial_invalidations

std::atomic<size_t> helios::ecs::details::QueryCacheStats::partial_invalidations {0}

Number of partial (component-specific) invalidations.

Definition at line 110 of file query_cache.hpp.

110{0}; ///< Number of partial (component-specific) invalidations

◆ total_queries

std::atomic<size_t> helios::ecs::details::QueryCacheStats::total_queries {0}

Total number of queries executed.

Definition at line 108 of file query_cache.hpp.

108{0}; ///< Total number of queries executed