Skip to content
Flecs v4.1
stats.h
Go to the documentation of this file.
1/**
2 * @file addons/stats.h
3 * @brief Statistics addon.
4 *
5 * The stats addon tracks high-resolution statistics for the world, systems, and
6 * pipelines. The addon can be used as an API where an application calls
7 * functions to obtain statistics directly and as a module where statistics are
8 * automatically tracked. The latter is required for statistics tracking in the
9 * explorer.
10 *
11 * When the addon is imported as a module, statistics are tracked for each frame,
12 * second, minute, hour, day, and week with 60 data points per tier.
13 */
14
15#ifdef FLECS_STATS
16
17/**
18 * @defgroup c_addons_stats Stats
19 * @ingroup c_addons
20 * Collection of statistics for world, queries, systems, and pipelines.
21 *
22 * @{
23 */
24
25#ifndef FLECS_STATS_H
26#define FLECS_STATS_H
27
28#ifndef FLECS_MODULE
29#define FLECS_MODULE
30#endif
31
32#ifndef FLECS_PIPELINE
33#define FLECS_PIPELINE
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/** Number of samples in the stat window. */
41#define ECS_STAT_WINDOW (60)
42
43/** Simple value that indicates current state. */
44typedef struct ecs_gauge_t {
45 ecs_float_t avg[ECS_STAT_WINDOW]; /**< Windowed average. */
46 ecs_float_t min[ECS_STAT_WINDOW]; /**< Windowed minimum. */
47 ecs_float_t max[ECS_STAT_WINDOW]; /**< Windowed maximum. */
49
50/** Monotonically increasing counter. */
51typedef struct ecs_counter_t {
52 ecs_gauge_t rate; /**< Keep track of deltas too. */
53 double value[ECS_STAT_WINDOW]; /**< Monotonically increasing values. */
55
56/** Make all metrics the same size, so we can iterate over fields. */
57typedef union ecs_metric_t {
58 ecs_gauge_t gauge; /**< Gauge metric. */
59 ecs_counter_t counter; /**< Counter metric. */
61
62/** Type that contains world statistics. */
63typedef struct ecs_world_stats_t {
64 int64_t first_; /**< Used for field iteration. Do not set. */
65
66 /* Entities */
67 struct {
68 ecs_metric_t count; /**< Number of entities. */
69 ecs_metric_t not_alive_count; /**< Number of not alive (recyclable) entity IDs. */
70 } entities;
71
72 /* Component IDs */
73 struct {
74 ecs_metric_t tag_count; /**< Number of tag IDs (IDs without data). */
75 ecs_metric_t component_count; /**< Number of component IDs (IDs with data). */
76 ecs_metric_t pair_count; /**< Number of pair IDs. */
77 ecs_metric_t type_count; /**< Number of registered types. */
78 ecs_metric_t create_count; /**< Number of times an ID has been created. */
79 ecs_metric_t delete_count; /**< Number of times an ID has been deleted. */
80 } components;
81
82 /* Tables */
83 struct {
84 ecs_metric_t count; /**< Number of tables. */
85 ecs_metric_t empty_count; /**< Number of empty tables. */
86 ecs_metric_t create_count; /**< Number of times table has been created. */
87 ecs_metric_t delete_count; /**< Number of times table has been deleted. */
88 } tables;
89
90 /* Queries and events */
91 struct {
92 ecs_metric_t query_count; /**< Number of queries. */
93 ecs_metric_t observer_count; /**< Number of observers. */
94 ecs_metric_t system_count; /**< Number of systems. */
95 } queries;
96
97 /* Commands */
98 struct {
99 ecs_metric_t add_count; /**< Number of add commands. */
100 ecs_metric_t remove_count; /**< Number of remove commands. */
101 ecs_metric_t delete_count; /**< Number of delete commands. */
102 ecs_metric_t clear_count; /**< Number of clear commands. */
103 ecs_metric_t set_count; /**< Number of set commands. */
104 ecs_metric_t ensure_count; /**< Number of ensure commands. */
105 ecs_metric_t modified_count; /**< Number of modified commands. */
106 ecs_metric_t other_count; /**< Number of other commands. */
107 ecs_metric_t discard_count; /**< Number of discarded commands. */
108 ecs_metric_t batched_entity_count; /**< Number of entities for which commands were batched. */
109 ecs_metric_t batched_count; /**< Number of commands batched. */
110 } commands;
111
112 /* Frame data */
113 struct {
114 ecs_metric_t frame_count; /**< Number of frames processed. */
115 ecs_metric_t merge_count; /**< Number of merges executed. */
116 ecs_metric_t rematch_count; /**< Number of query rematches. */
117 ecs_metric_t pipeline_build_count; /**< Number of system pipeline rebuilds (occurs when an inactive system becomes active). */
118 ecs_metric_t systems_ran; /**< Number of systems run. */
119 ecs_metric_t observers_ran; /**< Number of times an observer was invoked. */
120 ecs_metric_t event_emit_count; /**< Number of events emitted. */
121 } frame;
122
123 /* Timing */
124 struct {
125 ecs_metric_t world_time_raw; /**< Actual time passed since simulation start (first time progress() is called). */
126 ecs_metric_t world_time; /**< Simulation time passed since simulation start. Takes into account time scaling. */
127 ecs_metric_t frame_time; /**< Time spent processing a frame. Smaller than world_time_total when load is not 100%. */
128 ecs_metric_t system_time; /**< Time spent on running systems. */
129 ecs_metric_t emit_time; /**< Time spent on notifying observers. */
130 ecs_metric_t merge_time; /**< Time spent on merging commands. */
131 ecs_metric_t rematch_time; /**< Time spent on rematching. */
132 ecs_metric_t fps; /**< Frames per second. */
133 ecs_metric_t delta_time; /**< Delta time. */
134 } performance;
135
136 struct {
137 /* Memory allocation data */
138 ecs_metric_t alloc_count; /**< Allocs per frame. */
139 ecs_metric_t realloc_count; /**< Reallocs per frame. */
140 ecs_metric_t free_count; /**< Frees per frame. */
141 ecs_metric_t outstanding_alloc_count; /**< Difference between allocs and frees. */
142
143 /* Memory allocator data */
144 ecs_metric_t block_alloc_count; /**< Block allocations per frame. */
145 ecs_metric_t block_free_count; /**< Block frees per frame. */
146 ecs_metric_t block_outstanding_alloc_count; /**< Difference between allocs and frees. */
147 ecs_metric_t stack_alloc_count; /**< Page allocations per frame. */
148 ecs_metric_t stack_free_count; /**< Page frees per frame. */
149 ecs_metric_t stack_outstanding_alloc_count; /**< Difference between allocs and frees. */
150 } memory;
151
152 /* HTTP statistics */
153 struct {
154 ecs_metric_t request_received_count; /**< Number of HTTP requests received. */
155 ecs_metric_t request_invalid_count; /**< Number of invalid HTTP requests. */
156 ecs_metric_t request_handled_ok_count; /**< Number of successfully handled HTTP requests. */
157 ecs_metric_t request_handled_error_count; /**< Number of HTTP requests with error response. */
158 ecs_metric_t request_not_handled_count; /**< Number of unhandled HTTP requests. */
159 ecs_metric_t request_preflight_count; /**< Number of preflight HTTP requests. */
160 ecs_metric_t send_ok_count; /**< Number of successful HTTP responses sent. */
161 ecs_metric_t send_error_count; /**< Number of HTTP responses with send error. */
162 ecs_metric_t busy_count; /**< Number of times server was busy. */
163 } http;
164
165 int64_t last_; /**< Used for field iteration. Do not set. */
166
167 /** Current position in ring buffer. */
168 int32_t t;
170
171/** Statistics for a single query (use ecs_query_cache_stats_get()). */
172typedef struct ecs_query_stats_t {
173 int64_t first_; /**< Used for field iteration. Do not set. */
174 ecs_metric_t result_count; /**< Number of query results. */
175 ecs_metric_t matched_table_count; /**< Number of matched tables. */
176 ecs_metric_t matched_entity_count; /**< Number of matched entities. */
177 int64_t last_; /**< Used for field iteration. Do not set. */
178
179 /** Current position in ring buffer. */
180 int32_t t;
182
183/** Statistics for a single system (use ecs_system_stats_get()). */
184typedef struct ecs_system_stats_t {
185 int64_t first_; /**< Used for field iteration. Do not set. */
186 ecs_metric_t time_spent; /**< Time spent processing a system. */
187 int64_t last_; /**< Used for field iteration. Do not set. */
188
189 bool task; /**< Whether the system is a task. */
190
191 ecs_query_stats_t query; /**< Query statistics. */
193
194/** Statistics for sync point. */
195typedef struct ecs_sync_stats_t {
196 int64_t first_; /**< Used for field iteration. Do not set. */
197 ecs_metric_t time_spent; /**< Time spent in sync point. */
198 ecs_metric_t commands_enqueued; /**< Number of commands enqueued. */
199 int64_t last_; /**< Used for field iteration. Do not set. */
200
201 int32_t system_count; /**< Number of systems before sync point. */
202 bool multi_threaded; /**< Whether the sync point is multi-threaded. */
203 bool immediate; /**< Whether the sync point is immediate. */
205
206/** Statistics for all systems in a pipeline. */
207typedef struct ecs_pipeline_stats_t {
208 int8_t canary_; /**< Allow for initializing struct with {0}. Do not set. */
209
210 /** Vector with system IDs of all systems in the pipeline. The systems are
211 * stored in the order they are executed. Merges are represented by a 0. */
212 ecs_vec_t systems;
213
214 /** Vector with sync point stats. */
215 ecs_vec_t sync_points;
216
217 /** Current position in ring buffer. */
218 int32_t t;
219
220 int32_t system_count; /**< Number of systems in pipeline. */
221 int32_t active_system_count; /**< Number of active systems in pipeline. */
222 int32_t rebuild_count; /**< Number of times pipeline has rebuilt. */
224
225/** Get world statistics.
226 *
227 * @param world The world.
228 * @param stats Out parameter for statistics.
229 */
230FLECS_API
232 const ecs_world_t *world,
233 ecs_world_stats_t *stats);
234
235/** Reduce source measurement window into single destination measurement. */
236FLECS_API
239 const ecs_world_stats_t *src);
240
241/** Reduce last measurement into previous measurement, restore old value. */
242FLECS_API
244 ecs_world_stats_t *stats,
245 const ecs_world_stats_t *old,
246 int32_t count);
247
248/** Repeat last measurement. */
249FLECS_API
251 ecs_world_stats_t *stats);
252
253/** Copy last measurement from source to destination. */
254FLECS_API
257 const ecs_world_stats_t *src);
258
259/** Log world statistics.
260 *
261 * @param world The world.
262 * @param stats The statistics to log.
263 */
264FLECS_API
266 const ecs_world_t *world,
267 const ecs_world_stats_t *stats);
268
269/** Get query statistics.
270 * Obtain statistics for the provided query.
271 *
272 * @param world The world.
273 * @param query The query.
274 * @param stats Out parameter for statistics.
275 */
276FLECS_API
278 const ecs_world_t *world,
279 const ecs_query_t *query,
280 ecs_query_stats_t *stats);
281
282/** Reduce source measurement window into single destination measurement. */
283FLECS_API
286 const ecs_query_stats_t *src);
287
288/** Reduce last measurement into previous measurement, restore old value. */
289FLECS_API
291 ecs_query_stats_t *stats,
292 const ecs_query_stats_t *old,
293 int32_t count);
294
295/** Repeat last measurement. */
296FLECS_API
298 ecs_query_stats_t *stats);
299
300/** Copy last measurement from source to destination. */
301FLECS_API
304 const ecs_query_stats_t *src);
305
306/** Get system statistics.
307 * Obtain statistics for the provided system.
308 *
309 * @param world The world.
310 * @param system The system.
311 * @param stats Out parameter for statistics.
312 * @return true if success, false if not a system.
313 */
314FLECS_API
316 const ecs_world_t *world,
317 ecs_entity_t system,
318 ecs_system_stats_t *stats);
319
320/** Reduce source measurement window into single destination measurement. */
321FLECS_API
324 const ecs_system_stats_t *src);
325
326/** Reduce last measurement into previous measurement, restore old value. */
327FLECS_API
329 ecs_system_stats_t *stats,
330 const ecs_system_stats_t *old,
331 int32_t count);
332
333/** Repeat last measurement. */
334FLECS_API
336 ecs_system_stats_t *stats);
337
338/** Copy last measurement from source to destination. */
339FLECS_API
342 const ecs_system_stats_t *src);
343
344/** Get pipeline statistics.
345 * Obtain statistics for the provided pipeline.
346 *
347 * @param world The world.
348 * @param pipeline The pipeline.
349 * @param stats Out parameter for statistics.
350 * @return true if success, false if not a pipeline.
351 */
352FLECS_API
354 ecs_world_t *world,
355 ecs_entity_t pipeline,
356 ecs_pipeline_stats_t *stats);
357
358/** Free pipeline stats.
359 *
360 * @param stats The stats to free.
361 */
362FLECS_API
364 ecs_pipeline_stats_t *stats);
365
366/** Reduce source measurement window into single destination measurement. */
367FLECS_API
370 const ecs_pipeline_stats_t *src);
371
372/** Reduce last measurement into previous measurement, restore old value. */
373FLECS_API
376 const ecs_pipeline_stats_t *old,
377 int32_t count);
378
379/** Repeat last measurement. */
380FLECS_API
382 ecs_pipeline_stats_t *stats);
383
384/** Copy last measurement to destination.
385 * This operation copies the last measurement into the destination. It does not
386 * modify the cursor.
387 *
388 * @param dst The metrics.
389 * @param src The metrics to copy.
390 */
391FLECS_API
394 const ecs_pipeline_stats_t *src);
395
396/** Reduce all measurements from a window into a single measurement. */
397FLECS_API
399 ecs_metric_t *dst,
400 const ecs_metric_t *src,
401 int32_t t_dst,
402 int32_t t_src);
403
404/** Reduce last measurement into previous measurement. */
405FLECS_API
407 ecs_metric_t *m,
408 int32_t t,
409 int32_t count);
410
411/** Copy measurement. */
412FLECS_API
414 ecs_metric_t *m,
415 int32_t dst,
416 int32_t src);
417
418FLECS_API extern ECS_COMPONENT_DECLARE(FlecsStats); /**< Flecs stats module. */
419FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldStats); /**< Component ID for EcsWorldStats. */
420FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldSummary); /**< Component ID for EcsWorldSummary. */
421FLECS_API extern ECS_COMPONENT_DECLARE(EcsSystemStats); /**< Component ID for EcsSystemStats. */
422FLECS_API extern ECS_COMPONENT_DECLARE(EcsPipelineStats); /**< Component ID for EcsPipelineStats. */
423
424/* Memory statistics components */
425FLECS_API extern ECS_COMPONENT_DECLARE(ecs_entities_memory_t); /**< Component ID for ecs_entities_memory_t. */
426FLECS_API extern ECS_COMPONENT_DECLARE(ecs_component_index_memory_t); /**< Component ID for ecs_component_index_memory_t. */
427FLECS_API extern ECS_COMPONENT_DECLARE(ecs_query_memory_t); /**< Component ID for ecs_query_memory_t. */
428FLECS_API extern ECS_COMPONENT_DECLARE(ecs_component_memory_t); /**< Component ID for ecs_component_memory_t. */
429FLECS_API extern ECS_COMPONENT_DECLARE(ecs_table_memory_t); /**< Component ID for ecs_table_memory_t. */
430FLECS_API extern ECS_COMPONENT_DECLARE(ecs_misc_memory_t); /**< Component ID for ecs_misc_memory_t. */
431FLECS_API extern ECS_COMPONENT_DECLARE(ecs_table_histogram_t); /**< Component ID for ecs_table_histogram_t. */
432FLECS_API extern ECS_COMPONENT_DECLARE(ecs_allocator_memory_t); /**< Component ID for ecs_allocator_memory_t. */
433FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldMemory); /**< Component ID for EcsWorldMemory. */
434
435FLECS_API extern ecs_entity_t EcsPeriod1s; /**< Tag used for metrics collected in last second. */
436FLECS_API extern ecs_entity_t EcsPeriod1m; /**< Tag used for metrics collected in last minute. */
437FLECS_API extern ecs_entity_t EcsPeriod1h; /**< Tag used for metrics collected in last hour. */
438FLECS_API extern ecs_entity_t EcsPeriod1d; /**< Tag used for metrics collected in last day. */
439FLECS_API extern ecs_entity_t EcsPeriod1w; /**< Tag used for metrics collected in last week. */
440
441/** Common header for statistics types. */
442typedef struct {
443 ecs_ftime_t elapsed; /**< Elapsed time since last reset. */
444 int32_t reduce_count; /**< Number of times statistics have been reduced. */
446
447/** Component that stores world statistics. */
448typedef struct {
449 EcsStatsHeader hdr; /**< Statistics header. */
450 ecs_world_stats_t *stats; /**< World statistics data. */
452
453/** Component that stores system statistics. */
454typedef struct {
455 EcsStatsHeader hdr; /**< Statistics header. */
456 ecs_map_t stats; /**< Map of system statistics. */
458
459/** Component that stores pipeline statistics. */
460typedef struct {
461 EcsStatsHeader hdr; /**< Statistics header. */
462 ecs_map_t stats; /**< Map of pipeline statistics. */
464
465/** Component that stores a summary of world statistics. */
466typedef struct {
467 /* Time */
468 double target_fps; /**< Target FPS. */
469 double time_scale; /**< Simulation time scale. */
470 double fps; /**< FPS. */
471
472 /* Totals */
473 double frame_time_total; /**< Total time spent processing a frame. */
474 double system_time_total; /**< Total time spent in systems. */
475 double merge_time_total; /**< Total time spent in merges. */
476
477 int64_t entity_count; /**< Number of entities. */
478 int64_t table_count; /**< Number of tables. */
479 int64_t frame_count; /**< Number of frames processed. */
480 int64_t command_count; /**< Number of commands processed. */
481 int64_t merge_count; /**< Number of merges executed. */
482
483 int64_t systems_ran_total; /**< Total number of systems run. */
484 int64_t observers_ran_total; /**< Total number of times observers were invoked. */
485 int64_t queries_ran_total; /**< Total number of queries run. */
486
487 int32_t tag_count; /**< Number of tag (no data) IDs in the world. */
488 int32_t component_count; /**< Number of component (data) IDs in the world. */
489 int32_t pair_count; /**< Number of pair IDs in the world. */
490
491 /* Per frame */
492 double frame_time_frame; /**< Time spent processing a frame. */
493 double system_time_frame; /**< Time spent in systems. */
494 double merge_time_frame; /**< Time spent in merges. */
495
496 int64_t merge_count_frame; /**< Number of merges in last frame. */
497 int64_t systems_ran_frame; /**< Number of systems run in last frame. */
498 int64_t observers_ran_frame; /**< Number of times observers were invoked in last frame. */
499 int64_t queries_ran_frame; /**< Number of queries run in last frame. */
500 int64_t command_count_frame; /**< Number of commands processed in last frame. */
501
502 double simulation_time; /**< Time spent in simulation. */
503 uint32_t uptime; /**< Time since world was created. */
504
505 /* Build info */
506 ecs_build_info_t build_info; /**< Build info. */
508
509/** Entity memory. */
510typedef struct {
511 int32_t alive_count; /**< Number of alive entities. */
512 int32_t not_alive_count; /**< Number of not alive entities. */
513 ecs_size_t bytes_entity_index; /**< Bytes used by entity index. */
514 ecs_size_t bytes_names; /**< Bytes used by names, symbols, and aliases. */
515 ecs_size_t bytes_doc_strings; /**< Bytes used by doc strings. */
517
518/** Component memory. */
519typedef struct {
520 int32_t instances; /**< Total number of component instances. */
521 ecs_size_t bytes_table_components; /**< Bytes used by table columns. */
522 ecs_size_t bytes_table_components_unused; /**< Unused bytes in table columns. */
523 ecs_size_t bytes_toggle_bitsets; /**< Bytes used in bitsets (toggled components). */
524 ecs_size_t bytes_sparse_components; /**< Bytes used in component sparse sets. */
526
527/** Component index memory. */
528typedef struct {
529 int32_t count; /**< Number of component records. */
530 ecs_size_t bytes_component_record; /**< Bytes used by ecs_component_record_t struct. */
531 ecs_size_t bytes_table_cache; /**< Bytes used by table cache. */
532 ecs_size_t bytes_name_index; /**< Bytes used by name index. */
533 ecs_size_t bytes_ordered_children; /**< Bytes used by ordered children vector. */
534 ecs_size_t bytes_reachable_cache; /**< Bytes used by reachable cache. */
536
537/** Query memory. */
538typedef struct {
539 int32_t count; /**< Number of queries. */
540 int32_t cached_count; /**< Number of queries with caches. */
541 ecs_size_t bytes_query; /**< Bytes used by ecs_query_impl_t struct. */
542 ecs_size_t bytes_cache; /**< Bytes used by query cache. */
543 ecs_size_t bytes_group_by; /**< Bytes used by query cache groups (excludes cache elements). */
544 ecs_size_t bytes_order_by; /**< Bytes used by table_slices. */
545 ecs_size_t bytes_plan; /**< Bytes used by query plan. */
546 ecs_size_t bytes_terms; /**< Bytes used by terms array. */
547 ecs_size_t bytes_misc; /**< Bytes used by remaining misc arrays. */
549
550/** Table memory histogram constants. */
551#define ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT 14
552#define ECS_TABLE_MEMORY_HISTOGRAM_MAX_COUNT (1 << ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT)
553
554/** Table memory. */
555typedef struct {
556 int32_t count; /**< Total number of tables. */
557 int32_t empty_count; /**< Number of empty tables. */
558 int32_t column_count; /**< Number of table columns. */
559 ecs_size_t bytes_table; /**< Bytes used by ecs_table_t struct. */
560 ecs_size_t bytes_type; /**< Bytes used by type, columns, and table records. */
561 ecs_size_t bytes_entities; /**< Bytes used by entity vectors. */
562 ecs_size_t bytes_overrides; /**< Bytes used by table overrides. */
563 ecs_size_t bytes_column_map; /**< Bytes used by column map. */
564 ecs_size_t bytes_component_map; /**< Bytes used by component map. */
565 ecs_size_t bytes_dirty_state; /**< Bytes used by dirty state. */
566 ecs_size_t bytes_edges; /**< Bytes used by table graph edges. */
568
569/** Table size histogram. */
570typedef struct {
571 int32_t entity_counts[ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT]; /**< Entity count histogram buckets. */
573
574/** Misc memory. */
575typedef struct {
576 ecs_size_t bytes_world; /**< Memory used by world and stages. */
577 ecs_size_t bytes_observers; /**< Memory used by observers. */
578 ecs_size_t bytes_systems; /**< Memory used by systems (excluding system queries). */
579 ecs_size_t bytes_pipelines; /**< Memory used by pipelines (excluding pipeline queries). */
580 ecs_size_t bytes_table_lookup; /**< Bytes used for table lookup data structures. */
581 ecs_size_t bytes_component_record_lookup; /**< Bytes used for component record lookup data structures. */
582 ecs_size_t bytes_locked_components; /**< Locked component map. */
583 ecs_size_t bytes_type_info; /**< Bytes used for storing type information. */
584 ecs_size_t bytes_commands; /**< Command queue. */
585 ecs_size_t bytes_rematch_monitor; /**< Memory used by monitor used to track rematches. */
586 ecs_size_t bytes_component_ids; /**< Memory used for mapping global to world-local component ids. */
587 ecs_size_t bytes_reflection; /**< Memory used for component reflection not tracked elsewhere. */
588 ecs_size_t bytes_tree_spawner; /**< Memory used for tree (prefab) spawners. */
589 ecs_size_t bytes_prefab_child_indices; /**< Memory used by map that stores indices for ordered prefab children. */
590 ecs_size_t bytes_stats; /**< Memory used for statistics tracking not tracked elsewhere. */
591 ecs_size_t bytes_rest; /**< Memory used by REST HTTP server. */
593
594/** Allocator memory.
595 * Memory that is allocated by allocators but not in use. */
596typedef struct {
597 ecs_size_t bytes_graph_edge; /**< Graph edge allocator. */
598 ecs_size_t bytes_component_record; /**< Component record allocator. */
599 ecs_size_t bytes_pair_record; /**< Pair record allocator. */
600 ecs_size_t bytes_table_diff; /**< Table diff allocator. */
601 ecs_size_t bytes_sparse_chunk; /**< Sparse chunk allocator. */
602 ecs_size_t bytes_allocator; /**< Generic allocator. */
603 ecs_size_t bytes_stack_allocator; /**< Stack allocator. */
604 ecs_size_t bytes_cmd_entry_chunk; /**< Command batching entry chunk allocator. */
605 ecs_size_t bytes_query_impl; /**< Query struct allocator. */
606 ecs_size_t bytes_query_cache; /**< Query cache struct allocator. */
607 ecs_size_t bytes_misc; /**< Miscellaneous allocators. */
609
610/** Component with memory statistics. */
611typedef struct {
612 ecs_entities_memory_t entities; /**< Entity memory. */
613 ecs_component_memory_t components; /**< Component memory. */
614 ecs_component_index_memory_t component_index; /**< Component index memory. */
615 ecs_query_memory_t queries; /**< Query memory. */
616 ecs_table_memory_t tables; /**< Table memory. */
617 ecs_table_histogram_t table_histogram; /**< Table size histogram. */
618 ecs_misc_memory_t misc; /**< Miscellaneous memory. */
619 ecs_allocator_memory_t allocators; /**< Allocator memory. */
620 double collection_time; /**< Time spent collecting statistics. */
622
623/** Get memory usage statistics for the entity index.
624 *
625 * @param world The world.
626 * @return Memory statistics for the entity index.
627 */
628FLECS_API
630 const ecs_world_t *world);
631
632/** Get memory usage statistics for single component record.
633 *
634 * @param cr The component record.
635 * @param result Memory statistics for component record (out).
636 */
638 const ecs_component_record_t *cr,
640
641/** Get memory usage statistics for the component index.
642 *
643 * @param world The world.
644 * @return Memory statistics for the component index.
645 */
646FLECS_API
648 const ecs_world_t *world);
649
650/** Get memory usage statistics for single query.
651 *
652 * @param query The query.
653 * @param result Memory statistics for query (out).
654 */
655FLECS_API
657 const ecs_query_t *query,
658 ecs_query_memory_t *result);
659
660/** Get memory usage statistics for queries.
661 *
662 * @param world The world.
663 * @return Memory statistics for queries.
664 */
665FLECS_API
667 const ecs_world_t *world);
668
669/** Get component memory for table.
670 *
671 * @param table The table.
672 * @param result The memory used by components stored in this table (out).
673 */
675 const ecs_table_t *table,
676 ecs_component_memory_t *result);
677
678/** Get memory usage statistics for components.
679 *
680 * @param world The world.
681 * @return Memory statistics for components.
682 */
683FLECS_API
685 const ecs_world_t *world);
686
687/** Get memory usage statistics for single table.
688 *
689 * @param table The table.
690 * @param result Memory statistics for table (out).
691 */
693 const ecs_table_t *table,
694 ecs_table_memory_t *result);
695
696/** Get memory usage statistics for tables.
697 *
698 * @param world The world.
699 * @return Memory statistics for tables.
700 */
701FLECS_API
703 const ecs_world_t *world);
704
705/** Get number of tables by number of entities in the table.
706 *
707 * @param world The world.
708 * @return Number of tables by number of entities in the table.
709 */
710FLECS_API
712 const ecs_world_t *world);
713
714/** Get memory usage statistics for miscellaneous allocations.
715 *
716 * @param world The world.
717 * @return Memory statistics for miscellaneous allocations.
718 */
719FLECS_API
721 const ecs_world_t *world);
722
723/** Get memory usage statistics for allocators.
724 *
725 * @param world The world.
726 * @return Memory statistics for allocators.
727 */
728FLECS_API
730 const ecs_world_t *world);
731
732/** Get total memory used by world.
733 *
734 * @param world The world.
735 * @return Total memory used in bytes.
736 */
737FLECS_API
738ecs_size_t ecs_memory_get(
739 const ecs_world_t *world);
740
741
742/** Stats module import function.
743 * Usage:
744 * @code
745 * ECS_IMPORT(world, FlecsStats)
746 * @endcode
747 *
748 * @param world The world.
749 */
750FLECS_API
752 ecs_world_t *world);
753
754#ifdef __cplusplus
755}
756#endif
757
758#endif
759
760/** @} */
761
762#endif
FLECS_API ecs_size_t ecs_memory_get(const ecs_world_t *world)
Get total memory used by world.
FLECS_API void ecs_world_stats_reduce(ecs_world_stats_t *dst, const ecs_world_stats_t *src)
Reduce source measurement window into single destination measurement.
FLECS_API void ecs_query_stats_get(const ecs_world_t *world, const ecs_query_t *query, ecs_query_stats_t *stats)
Get query statistics.
FLECS_API void ecs_query_cache_stats_reduce_last(ecs_query_stats_t *stats, const ecs_query_stats_t *old, int32_t count)
Reduce last measurement into previous measurement, restore old value.
FLECS_API void ecs_world_stats_get(const ecs_world_t *world, ecs_world_stats_t *stats)
Get world statistics.
FLECS_API ecs_entity_t EcsPeriod1s
Tag used for metrics collected in last second.
#define ECS_STAT_WINDOW
Number of samples in the stat window.
Definition stats.h:41
FLECS_API ecs_query_memory_t ecs_queries_memory_get(const ecs_world_t *world)
Get memory usage statistics for queries.
#define ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT
Table memory histogram constants.
Definition stats.h:551
FLECS_API ecs_entity_t EcsPeriod1h
Tag used for metrics collected in last hour.
FLECS_API void ecs_pipeline_stats_reduce_last(ecs_pipeline_stats_t *stats, const ecs_pipeline_stats_t *old, int32_t count)
Reduce last measurement into previous measurement, restore old value.
FLECS_API ecs_component_memory_t ecs_component_memory_get(const ecs_world_t *world)
Get memory usage statistics for components.
FLECS_API ecs_misc_memory_t ecs_misc_memory_get(const ecs_world_t *world)
Get memory usage statistics for miscellaneous allocations.
FLECS_API void ecs_query_cache_stats_repeat_last(ecs_query_stats_t *stats)
Repeat last measurement.
FLECS_API void ecs_metric_reduce_last(ecs_metric_t *m, int32_t t, int32_t count)
Reduce last measurement into previous measurement.
FLECS_API bool ecs_system_stats_get(const ecs_world_t *world, ecs_entity_t system, ecs_system_stats_t *stats)
Get system statistics.
FLECS_API void ecs_world_stats_reduce_last(ecs_world_stats_t *stats, const ecs_world_stats_t *old, int32_t count)
Reduce last measurement into previous measurement, restore old value.
FLECS_API ecs_allocator_memory_t ecs_allocator_memory_get(const ecs_world_t *world)
Get memory usage statistics for allocators.
FLECS_API ecs_table_histogram_t ecs_table_histogram_get(const ecs_world_t *world)
Get number of tables by number of entities in the table.
FLECS_API void ecs_query_cache_stats_reduce(ecs_query_stats_t *dst, const ecs_query_stats_t *src)
Reduce source measurement window into single destination measurement.
FLECS_API void ecs_query_memory_get(const ecs_query_t *query, ecs_query_memory_t *result)
Get memory usage statistics for single query.
FLECS_API void FlecsStatsImport(ecs_world_t *world)
Stats module import function.
FLECS_API void ecs_metric_copy(ecs_metric_t *m, int32_t dst, int32_t src)
Copy measurement.
FLECS_API ecs_entities_memory_t ecs_entity_memory_get(const ecs_world_t *world)
Get memory usage statistics for the entity index.
FLECS_API void ecs_pipeline_stats_repeat_last(ecs_pipeline_stats_t *stats)
Repeat last measurement.
FLECS_API void ecs_pipeline_stats_fini(ecs_pipeline_stats_t *stats)
Free pipeline stats.
FLECS_API void ecs_pipeline_stats_copy_last(ecs_pipeline_stats_t *dst, const ecs_pipeline_stats_t *src)
Copy last measurement to destination.
FLECS_API void ecs_system_stats_reduce(ecs_system_stats_t *dst, const ecs_system_stats_t *src)
Reduce source measurement window into single destination measurement.
FLECS_API ecs_table_memory_t ecs_tables_memory_get(const ecs_world_t *world)
Get memory usage statistics for tables.
FLECS_API void ecs_pipeline_stats_reduce(ecs_pipeline_stats_t *dst, const ecs_pipeline_stats_t *src)
Reduce source measurement window into single destination measurement.
FLECS_API void ecs_system_stats_copy_last(ecs_system_stats_t *dst, const ecs_system_stats_t *src)
Copy last measurement from source to destination.
FLECS_API void ecs_system_stats_repeat_last(ecs_system_stats_t *stats)
Repeat last measurement.
void ecs_table_component_memory_get(const ecs_table_t *table, ecs_component_memory_t *result)
Get component memory for table.
FLECS_API void ecs_world_stats_repeat_last(ecs_world_stats_t *stats)
Repeat last measurement.
FLECS_API void ecs_world_stats_copy_last(ecs_world_stats_t *dst, const ecs_world_stats_t *src)
Copy last measurement from source to destination.
FLECS_API void ecs_metric_reduce(ecs_metric_t *dst, const ecs_metric_t *src, int32_t t_dst, int32_t t_src)
Reduce all measurements from a window into a single measurement.
FLECS_API ecs_entity_t EcsPeriod1m
Tag used for metrics collected in last minute.
FLECS_API bool ecs_pipeline_stats_get(ecs_world_t *world, ecs_entity_t pipeline, ecs_pipeline_stats_t *stats)
Get pipeline statistics.
FLECS_API ecs_entity_t EcsPeriod1w
Tag used for metrics collected in last week.
void ecs_component_record_memory_get(const ecs_component_record_t *cr, ecs_component_index_memory_t *result)
Get memory usage statistics for single component record.
FLECS_API void ecs_system_stats_reduce_last(ecs_system_stats_t *stats, const ecs_system_stats_t *old, int32_t count)
Reduce last measurement into previous measurement, restore old value.
FLECS_API void ecs_world_stats_log(const ecs_world_t *world, const ecs_world_stats_t *stats)
Log world statistics.
FLECS_API ecs_entity_t EcsPeriod1d
Tag used for metrics collected in last day.
void ecs_table_memory_get(const ecs_table_t *table, ecs_table_memory_t *result)
Get memory usage statistics for single table.
FLECS_API ecs_component_index_memory_t ecs_component_index_memory_get(const ecs_world_t *world)
Get memory usage statistics for the component index.
FLECS_API void ecs_query_cache_stats_copy_last(ecs_query_stats_t *dst, const ecs_query_stats_t *src)
Copy last measurement from source to destination.
struct ecs_component_record_t ecs_component_record_t
Information about a (component) ID, such as type info and tables with the ID.
Definition flecs.h:507
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:395
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:439
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:445
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:65
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
#define ecs_float_t
Customizable precision for floating-point operations.
Definition flecs.h:52
Component that stores pipeline statistics.
Definition stats.h:460
EcsStatsHeader hdr
Statistics header.
Definition stats.h:461
ecs_map_t stats
Map of pipeline statistics.
Definition stats.h:462
Common header for statistics types.
Definition stats.h:442
int32_t reduce_count
Number of times statistics have been reduced.
Definition stats.h:444
ecs_ftime_t elapsed
Elapsed time since last reset.
Definition stats.h:443
Component that stores system statistics.
Definition stats.h:454
ecs_map_t stats
Map of system statistics.
Definition stats.h:456
EcsStatsHeader hdr
Statistics header.
Definition stats.h:455
Component with memory statistics.
Definition stats.h:611
ecs_entities_memory_t entities
Entity memory.
Definition stats.h:612
ecs_query_memory_t queries
Query memory.
Definition stats.h:615
ecs_table_memory_t tables
Table memory.
Definition stats.h:616
ecs_table_histogram_t table_histogram
Table size histogram.
Definition stats.h:617
ecs_misc_memory_t misc
Miscellaneous memory.
Definition stats.h:618
double collection_time
Time spent collecting statistics.
Definition stats.h:620
ecs_allocator_memory_t allocators
Allocator memory.
Definition stats.h:619
ecs_component_memory_t components
Component memory.
Definition stats.h:613
ecs_component_index_memory_t component_index
Component index memory.
Definition stats.h:614
Component that stores world statistics.
Definition stats.h:448
ecs_world_stats_t * stats
World statistics data.
Definition stats.h:450
EcsStatsHeader hdr
Statistics header.
Definition stats.h:449
Component that stores a summary of world statistics.
Definition stats.h:466
int32_t component_count
Number of component (data) IDs in the world.
Definition stats.h:488
int64_t systems_ran_frame
Number of systems run in last frame.
Definition stats.h:497
int64_t queries_ran_total
Total number of queries run.
Definition stats.h:485
double frame_time_frame
Time spent processing a frame.
Definition stats.h:492
double simulation_time
Time spent in simulation.
Definition stats.h:502
int64_t entity_count
Number of entities.
Definition stats.h:477
double target_fps
Target FPS.
Definition stats.h:468
double merge_time_total
Total time spent in merges.
Definition stats.h:475
double system_time_frame
Time spent in systems.
Definition stats.h:493
int64_t table_count
Number of tables.
Definition stats.h:478
int64_t observers_ran_total
Total number of times observers were invoked.
Definition stats.h:484
int64_t systems_ran_total
Total number of systems run.
Definition stats.h:483
int64_t frame_count
Number of frames processed.
Definition stats.h:479
int64_t queries_ran_frame
Number of queries run in last frame.
Definition stats.h:499
int32_t pair_count
Number of pair IDs in the world.
Definition stats.h:489
ecs_build_info_t build_info
Build info.
Definition stats.h:506
int64_t merge_count
Number of merges executed.
Definition stats.h:481
int64_t command_count_frame
Number of commands processed in last frame.
Definition stats.h:500
double system_time_total
Total time spent in systems.
Definition stats.h:474
uint32_t uptime
Time since world was created.
Definition stats.h:503
double merge_time_frame
Time spent in merges.
Definition stats.h:494
double frame_time_total
Total time spent processing a frame.
Definition stats.h:473
int64_t merge_count_frame
Number of merges in last frame.
Definition stats.h:496
int32_t tag_count
Number of tag (no data) IDs in the world.
Definition stats.h:487
double time_scale
Simulation time scale.
Definition stats.h:469
double fps
FPS.
Definition stats.h:470
int64_t command_count
Number of commands processed.
Definition stats.h:480
int64_t observers_ran_frame
Number of times observers were invoked in last frame.
Definition stats.h:498
Allocator memory.
Definition stats.h:596
ecs_size_t bytes_sparse_chunk
Sparse chunk allocator.
Definition stats.h:601
ecs_size_t bytes_table_diff
Table diff allocator.
Definition stats.h:600
ecs_size_t bytes_graph_edge
Graph edge allocator.
Definition stats.h:597
ecs_size_t bytes_query_impl
Query struct allocator.
Definition stats.h:605
ecs_size_t bytes_allocator
Generic allocator.
Definition stats.h:602
ecs_size_t bytes_stack_allocator
Stack allocator.
Definition stats.h:603
ecs_size_t bytes_cmd_entry_chunk
Command batching entry chunk allocator.
Definition stats.h:604
ecs_size_t bytes_misc
Miscellaneous allocators.
Definition stats.h:607
ecs_size_t bytes_pair_record
Pair record allocator.
Definition stats.h:599
ecs_size_t bytes_query_cache
Query cache struct allocator.
Definition stats.h:606
ecs_size_t bytes_component_record
Component record allocator.
Definition stats.h:598
Type with information about the current Flecs build.
Definition flecs.h:1510
Component index memory.
Definition stats.h:528
int32_t count
Number of component records.
Definition stats.h:529
ecs_size_t bytes_component_record
Bytes used by ecs_component_record_t struct.
Definition stats.h:530
ecs_size_t bytes_ordered_children
Bytes used by ordered children vector.
Definition stats.h:533
ecs_size_t bytes_table_cache
Bytes used by table cache.
Definition stats.h:531
ecs_size_t bytes_name_index
Bytes used by name index.
Definition stats.h:532
ecs_size_t bytes_reachable_cache
Bytes used by reachable cache.
Definition stats.h:534
Component memory.
Definition stats.h:519
ecs_size_t bytes_sparse_components
Bytes used in component sparse sets.
Definition stats.h:524
int32_t instances
Total number of component instances.
Definition stats.h:520
ecs_size_t bytes_table_components_unused
Unused bytes in table columns.
Definition stats.h:522
ecs_size_t bytes_table_components
Bytes used by table columns.
Definition stats.h:521
ecs_size_t bytes_toggle_bitsets
Bytes used in bitsets (toggled components).
Definition stats.h:523
Monotonically increasing counter.
Definition stats.h:51
ecs_gauge_t rate
Keep track of deltas too.
Definition stats.h:52
double value[(60)]
Monotonically increasing values.
Definition stats.h:53
Entity memory.
Definition stats.h:510
int32_t alive_count
Number of alive entities.
Definition stats.h:511
int32_t not_alive_count
Number of not alive entities.
Definition stats.h:512
ecs_size_t bytes_doc_strings
Bytes used by doc strings.
Definition stats.h:515
ecs_size_t bytes_entity_index
Bytes used by entity index.
Definition stats.h:513
ecs_size_t bytes_names
Bytes used by names, symbols, and aliases.
Definition stats.h:514
Simple value that indicates current state.
Definition stats.h:44
ecs_float_t avg[(60)]
Windowed average.
Definition stats.h:45
ecs_float_t min[(60)]
Windowed minimum.
Definition stats.h:46
ecs_float_t max[(60)]
Windowed maximum.
Definition stats.h:47
Misc memory.
Definition stats.h:575
ecs_size_t bytes_component_ids
Memory used for mapping global to world-local component ids.
Definition stats.h:586
ecs_size_t bytes_observers
Memory used by observers.
Definition stats.h:577
ecs_size_t bytes_type_info
Bytes used for storing type information.
Definition stats.h:583
ecs_size_t bytes_reflection
Memory used for component reflection not tracked elsewhere.
Definition stats.h:587
ecs_size_t bytes_stats
Memory used for statistics tracking not tracked elsewhere.
Definition stats.h:590
ecs_size_t bytes_prefab_child_indices
Memory used by map that stores indices for ordered prefab children.
Definition stats.h:589
ecs_size_t bytes_systems
Memory used by systems (excluding system queries).
Definition stats.h:578
ecs_size_t bytes_locked_components
Locked component map.
Definition stats.h:582
ecs_size_t bytes_pipelines
Memory used by pipelines (excluding pipeline queries).
Definition stats.h:579
ecs_size_t bytes_world
Memory used by world and stages.
Definition stats.h:576
ecs_size_t bytes_rematch_monitor
Memory used by monitor used to track rematches.
Definition stats.h:585
ecs_size_t bytes_rest
Memory used by REST HTTP server.
Definition stats.h:591
ecs_size_t bytes_commands
Command queue.
Definition stats.h:584
ecs_size_t bytes_component_record_lookup
Bytes used for component record lookup data structures.
Definition stats.h:581
ecs_size_t bytes_tree_spawner
Memory used for tree (prefab) spawners.
Definition stats.h:588
ecs_size_t bytes_table_lookup
Bytes used for table lookup data structures.
Definition stats.h:580
Statistics for all systems in a pipeline.
Definition stats.h:207
int32_t rebuild_count
Number of times pipeline has rebuilt.
Definition stats.h:222
int32_t system_count
Number of systems in pipeline.
Definition stats.h:220
int8_t canary_
Allow for initializing struct with {0}.
Definition stats.h:208
ecs_vec_t systems
Vector with system IDs of all systems in the pipeline.
Definition stats.h:212
int32_t active_system_count
Number of active systems in pipeline.
Definition stats.h:221
ecs_vec_t sync_points
Vector with sync point stats.
Definition stats.h:215
int32_t t
Current position in ring buffer.
Definition stats.h:218
Query memory.
Definition stats.h:538
ecs_size_t bytes_cache
Bytes used by query cache.
Definition stats.h:542
ecs_size_t bytes_terms
Bytes used by terms array.
Definition stats.h:546
int32_t count
Number of queries.
Definition stats.h:539
ecs_size_t bytes_order_by
Bytes used by table_slices.
Definition stats.h:544
int32_t cached_count
Number of queries with caches.
Definition stats.h:540
ecs_size_t bytes_query
Bytes used by ecs_query_impl_t struct.
Definition stats.h:541
ecs_size_t bytes_misc
Bytes used by remaining misc arrays.
Definition stats.h:547
ecs_size_t bytes_group_by
Bytes used by query cache groups (excludes cache elements).
Definition stats.h:543
ecs_size_t bytes_plan
Bytes used by query plan.
Definition stats.h:545
Statistics for a single query (use ecs_query_cache_stats_get()).
Definition stats.h:172
ecs_metric_t result_count
Number of query results.
Definition stats.h:174
int32_t t
Current position in ring buffer.
Definition stats.h:180
ecs_metric_t matched_table_count
Number of matched tables.
Definition stats.h:175
ecs_metric_t matched_entity_count
Number of matched entities.
Definition stats.h:176
int64_t first_
Used for field iteration.
Definition stats.h:173
int64_t last_
Used for field iteration.
Definition stats.h:177
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:858
Statistics for sync point.
Definition stats.h:195
ecs_metric_t time_spent
Time spent in sync point.
Definition stats.h:197
int64_t first_
Used for field iteration.
Definition stats.h:196
int64_t last_
Used for field iteration.
Definition stats.h:199
int32_t system_count
Number of systems before sync point.
Definition stats.h:201
bool immediate
Whether the sync point is immediate.
Definition stats.h:203
ecs_metric_t commands_enqueued
Number of commands enqueued.
Definition stats.h:198
bool multi_threaded
Whether the sync point is multi-threaded.
Definition stats.h:202
Statistics for a single system (use ecs_system_stats_get()).
Definition stats.h:184
int64_t last_
Used for field iteration.
Definition stats.h:187
int64_t first_
Used for field iteration.
Definition stats.h:185
ecs_query_stats_t query
Query statistics.
Definition stats.h:191
bool task
Whether the system is a task.
Definition stats.h:189
ecs_metric_t time_spent
Time spent processing a system.
Definition stats.h:186
Table size histogram.
Definition stats.h:570
int32_t entity_counts[14]
Entity count histogram buckets.
Definition stats.h:571
Table memory.
Definition stats.h:555
ecs_size_t bytes_dirty_state
Bytes used by dirty state.
Definition stats.h:565
ecs_size_t bytes_type
Bytes used by type, columns, and table records.
Definition stats.h:560
ecs_size_t bytes_edges
Bytes used by table graph edges.
Definition stats.h:566
ecs_size_t bytes_table
Bytes used by ecs_table_t struct.
Definition stats.h:559
int32_t count
Total number of tables.
Definition stats.h:556
int32_t column_count
Number of table columns.
Definition stats.h:558
ecs_size_t bytes_overrides
Bytes used by table overrides.
Definition stats.h:562
ecs_size_t bytes_component_map
Bytes used by component map.
Definition stats.h:564
int32_t empty_count
Number of empty tables.
Definition stats.h:557
ecs_size_t bytes_entities
Bytes used by entity vectors.
Definition stats.h:561
ecs_size_t bytes_column_map
Bytes used by column map.
Definition stats.h:563
ecs_metric_t other_count
Number of other commands.
ecs_metric_t clear_count
Number of clear commands.
ecs_metric_t set_count
Number of set commands.
ecs_metric_t discard_count
Number of discarded commands.
ecs_metric_t add_count
Number of add commands.
ecs_metric_t ensure_count
Number of ensure commands.
ecs_metric_t batched_entity_count
Number of entities for which commands were batched.
ecs_metric_t remove_count
Number of remove commands.
ecs_metric_t modified_count
Number of modified commands.
ecs_metric_t batched_count
Number of commands batched.
ecs_metric_t delete_count
Number of delete commands.
ecs_metric_t type_count
Number of registered types.
ecs_metric_t create_count
Number of times an ID has been created.
ecs_metric_t tag_count
Number of tag IDs (IDs without data).
ecs_metric_t component_count
Number of component IDs (IDs with data).
ecs_metric_t delete_count
Number of times an ID has been deleted.
ecs_metric_t pair_count
Number of pair IDs.
ecs_metric_t not_alive_count
Number of not alive (recyclable) entity IDs.
ecs_metric_t count
Number of entities.
ecs_metric_t merge_count
Number of merges executed.
ecs_metric_t observers_ran
Number of times an observer was invoked.
ecs_metric_t frame_count
Number of frames processed.
ecs_metric_t systems_ran
Number of systems run.
ecs_metric_t rematch_count
Number of query rematches.
ecs_metric_t pipeline_build_count
Number of system pipeline rebuilds (occurs when an inactive system becomes active).
ecs_metric_t event_emit_count
Number of events emitted.
ecs_metric_t send_error_count
Number of HTTP responses with send error.
ecs_metric_t request_handled_ok_count
Number of successfully handled HTTP requests.
ecs_metric_t request_not_handled_count
Number of unhandled HTTP requests.
ecs_metric_t request_invalid_count
Number of invalid HTTP requests.
ecs_metric_t request_received_count
Number of HTTP requests received.
ecs_metric_t request_preflight_count
Number of preflight HTTP requests.
ecs_metric_t send_ok_count
Number of successful HTTP responses sent.
ecs_metric_t busy_count
Number of times server was busy.
ecs_metric_t request_handled_error_count
Number of HTTP requests with error response.
ecs_metric_t block_free_count
Block frees per frame.
ecs_metric_t stack_outstanding_alloc_count
Difference between allocs and frees.
ecs_metric_t realloc_count
Reallocs per frame.
ecs_metric_t outstanding_alloc_count
Difference between allocs and frees.
ecs_metric_t alloc_count
Allocs per frame.
ecs_metric_t block_alloc_count
Block allocations per frame.
ecs_metric_t stack_free_count
Page frees per frame.
ecs_metric_t free_count
Frees per frame.
ecs_metric_t block_outstanding_alloc_count
Difference between allocs and frees.
ecs_metric_t stack_alloc_count
Page allocations per frame.
ecs_metric_t merge_time
Time spent on merging commands.
ecs_metric_t world_time
Simulation time passed since simulation start.
ecs_metric_t rematch_time
Time spent on rematching.
ecs_metric_t emit_time
Time spent on notifying observers.
ecs_metric_t frame_time
Time spent processing a frame.
ecs_metric_t fps
Frames per second.
ecs_metric_t system_time
Time spent on running systems.
ecs_metric_t world_time_raw
Actual time passed since simulation start (first time progress() is called).
ecs_metric_t delta_time
Delta time.
ecs_metric_t observer_count
Number of observers.
ecs_metric_t query_count
Number of queries.
ecs_metric_t system_count
Number of systems.
ecs_metric_t delete_count
Number of times table has been deleted.
ecs_metric_t empty_count
Number of empty tables.
ecs_metric_t create_count
Number of times table has been created.
ecs_metric_t count
Number of tables.
Type that contains world statistics.
Definition stats.h:63
int32_t t
Current position in ring buffer.
Definition stats.h:168
int64_t last_
Used for field iteration.
Definition stats.h:165
int64_t first_
Used for field iteration.
Definition stats.h:64
Make all metrics the same size, so we can iterate over fields.
Definition stats.h:57
ecs_gauge_t gauge
Gauge metric.
Definition stats.h:58
ecs_counter_t counter
Counter metric.
Definition stats.h:59