Flecs: include/flecs/addons/stats.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
stats.h
Go to the documentation of this file.
1
14
15#ifdef FLECS_STATS
16
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#define ECS_STAT_WINDOW (60)
41
43 typedef struct ecs_gauge_t {
44 ecs_float_t avg[ECS_STAT_WINDOW];
45 ecs_float_t min[ECS_STAT_WINDOW];
46 ecs_float_t max[ECS_STAT_WINDOW];
47} ecs_gauge_t;
48
50 typedef struct ecs_counter_t {
51 ecs_gauge_t rate;
52 double value[ECS_STAT_WINDOW];
53} ecs_counter_t;
54
56 typedef union ecs_metric_t {
57 ecs_gauge_t gauge;
58 ecs_counter_t counter;
59} ecs_metric_t;
60
61 typedef struct ecs_world_stats_t {
62 int64_t first_;
63
64 /* Entities */
65 struct {
66 ecs_metric_t count;
67 ecs_metric_t not_alive_count;
68 } entities;
69
70 /* Component ids */
71 struct {
72 ecs_metric_t tag_count;
73 ecs_metric_t component_count;
74 ecs_metric_t pair_count;
75 ecs_metric_t type_count;
76 ecs_metric_t create_count;
77 ecs_metric_t delete_count;
78 } components;
79
80 /* Tables */
81 struct {
82 ecs_metric_t count;
83 ecs_metric_t empty_count;
84 ecs_metric_t create_count;
85 ecs_metric_t delete_count;
86 } tables;
87
88 /* Queries & events */
89 struct {
90 ecs_metric_t query_count;
91 ecs_metric_t observer_count;
92 ecs_metric_t system_count;
93 } queries;
94
95 /* Commands */
96 struct {
97 ecs_metric_t add_count;
98 ecs_metric_t remove_count;
99 ecs_metric_t delete_count;
100 ecs_metric_t clear_count;
101 ecs_metric_t set_count;
102 ecs_metric_t ensure_count;
103 ecs_metric_t modified_count;
104 ecs_metric_t other_count;
105 ecs_metric_t discard_count;
106 ecs_metric_t batched_entity_count;
107 ecs_metric_t batched_count;
108 } commands;
109
110 /* Frame data */
111 struct {
112 ecs_metric_t frame_count;
113 ecs_metric_t merge_count;
114 ecs_metric_t rematch_count;
115 ecs_metric_t pipeline_build_count;
116 ecs_metric_t systems_ran;
117 ecs_metric_t observers_ran;
118 ecs_metric_t event_emit_count;
119 } frame;
120
121 /* Timing */
122 struct {
123 ecs_metric_t world_time_raw;
124 ecs_metric_t world_time;
125 ecs_metric_t frame_time;
126 ecs_metric_t system_time;
127 ecs_metric_t emit_time;
128 ecs_metric_t merge_time;
129 ecs_metric_t rematch_time;
130 ecs_metric_t fps;
131 ecs_metric_t delta_time;
132 } performance;
133
134 struct {
135 /* Memory allocation data */
136 ecs_metric_t alloc_count;
137 ecs_metric_t realloc_count;
138 ecs_metric_t free_count;
139 ecs_metric_t outstanding_alloc_count;
140
141 /* Memory allocator data */
142 ecs_metric_t block_alloc_count;
143 ecs_metric_t block_free_count;
144 ecs_metric_t block_outstanding_alloc_count;
145 ecs_metric_t stack_alloc_count;
146 ecs_metric_t stack_free_count;
147 ecs_metric_t stack_outstanding_alloc_count;
148 } memory;
149
150 /* HTTP statistics */
151 struct {
152 ecs_metric_t request_received_count;
153 ecs_metric_t request_invalid_count;
154 ecs_metric_t request_handled_ok_count;
155 ecs_metric_t request_handled_error_count;
156 ecs_metric_t request_not_handled_count;
157 ecs_metric_t request_preflight_count;
158 ecs_metric_t send_ok_count;
159 ecs_metric_t send_error_count;
160 ecs_metric_t busy_count;
161 } http;
162
163 int64_t last_;
164
166 int32_t t;
167} ecs_world_stats_t;
168
170 typedef struct ecs_query_stats_t {
171 int64_t first_;
172 ecs_metric_t result_count;
173 ecs_metric_t matched_table_count;
174 ecs_metric_t matched_entity_count;
175 int64_t last_;
176
178 int32_t t;
179} ecs_query_stats_t;
180
182 typedef struct ecs_system_stats_t {
183 int64_t first_;
184 ecs_metric_t time_spent;
185 int64_t last_;
186
187 bool task;
188
189 ecs_query_stats_t query;
190} ecs_system_stats_t;
191
193 typedef struct ecs_sync_stats_t {
194 int64_t first_;
195 ecs_metric_t time_spent;
196 ecs_metric_t commands_enqueued;
197 int64_t last_;
198
199 int32_t system_count;
200 bool multi_threaded;
201 bool immediate;
202} ecs_sync_stats_t;
203
205 typedef struct ecs_pipeline_stats_t {
206 /* Allow for initializing struct with {0} */
207 int8_t canary_;
208
211 ecs_vec_t systems;
212
214 ecs_vec_t sync_points;
215
217 int32_t t;
218
219 int32_t system_count;
220 int32_t active_system_count;
221 int32_t rebuild_count;
222} ecs_pipeline_stats_t;
223
229FLECS_API
230 void ecs_world_stats_get(
231 const ecs_world_t *world,
232 ecs_world_stats_t *stats);
233
235FLECS_API
236 void ecs_world_stats_reduce(
237 ecs_world_stats_t *dst,
238 const ecs_world_stats_t *src);
239
241FLECS_API
242 void ecs_world_stats_reduce_last(
243 ecs_world_stats_t *stats,
244 const ecs_world_stats_t *old,
245 int32_t count);
246
248FLECS_API
249 void ecs_world_stats_repeat_last(
250 ecs_world_stats_t *stats);
251
253FLECS_API
254 void ecs_world_stats_copy_last(
255 ecs_world_stats_t *dst,
256 const ecs_world_stats_t *src);
257
258FLECS_API
259void ecs_world_stats_log(
260 const ecs_world_t *world,
261 const ecs_world_stats_t *stats);
262
270FLECS_API
271 void ecs_query_stats_get(
272 const ecs_world_t *world,
273 const ecs_query_t *query,
274 ecs_query_stats_t *stats);
275
277FLECS_API
278 void ecs_query_cache_stats_reduce(
279 ecs_query_stats_t *dst,
280 const ecs_query_stats_t *src);
281
283FLECS_API
284 void ecs_query_cache_stats_reduce_last(
285 ecs_query_stats_t *stats,
286 const ecs_query_stats_t *old,
287 int32_t count);
288
290FLECS_API
291 void ecs_query_cache_stats_repeat_last(
292 ecs_query_stats_t *stats);
293
295FLECS_API
296 void ecs_query_cache_stats_copy_last(
297 ecs_query_stats_t *dst,
298 const ecs_query_stats_t *src);
299
308FLECS_API
309 bool ecs_system_stats_get(
310 const ecs_world_t *world,
311 ecs_entity_t system,
312 ecs_system_stats_t *stats);
313
315FLECS_API
316 void ecs_system_stats_reduce(
317 ecs_system_stats_t *dst,
318 const ecs_system_stats_t *src);
319
321FLECS_API
322 void ecs_system_stats_reduce_last(
323 ecs_system_stats_t *stats,
324 const ecs_system_stats_t *old,
325 int32_t count);
326
328FLECS_API
329 void ecs_system_stats_repeat_last(
330 ecs_system_stats_t *stats);
331
333FLECS_API
334 void ecs_system_stats_copy_last(
335 ecs_system_stats_t *dst,
336 const ecs_system_stats_t *src);
337
346FLECS_API
347 bool ecs_pipeline_stats_get(
348 ecs_world_t *world,
349 ecs_entity_t pipeline,
350 ecs_pipeline_stats_t *stats);
351
356FLECS_API
357 void ecs_pipeline_stats_fini(
358 ecs_pipeline_stats_t *stats);
359
361FLECS_API
362 void ecs_pipeline_stats_reduce(
363 ecs_pipeline_stats_t *dst,
364 const ecs_pipeline_stats_t *src);
365
367FLECS_API
368 void ecs_pipeline_stats_reduce_last(
369 ecs_pipeline_stats_t *stats,
370 const ecs_pipeline_stats_t *old,
371 int32_t count);
372
374FLECS_API
375 void ecs_pipeline_stats_repeat_last(
376 ecs_pipeline_stats_t *stats);
377
385FLECS_API
386 void ecs_pipeline_stats_copy_last(
387 ecs_pipeline_stats_t *dst,
388 const ecs_pipeline_stats_t *src);
389
391FLECS_API
392 void ecs_metric_reduce(
393 ecs_metric_t *dst,
394 const ecs_metric_t *src,
395 int32_t t_dst,
396 int32_t t_src);
397
399FLECS_API
400 void ecs_metric_reduce_last(
401 ecs_metric_t *m,
402 int32_t t,
403 int32_t count);
404
406FLECS_API
407 void ecs_metric_copy(
408 ecs_metric_t *m,
409 int32_t dst,
410 int32_t src);
411
412FLECS_API extern ECS_COMPONENT_DECLARE(FlecsStats);
413FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldStats);
414FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldSummary);
415FLECS_API extern ECS_COMPONENT_DECLARE(EcsSystemStats);
416FLECS_API extern ECS_COMPONENT_DECLARE(EcsPipelineStats);
417
418/* Memory statistics components */
419FLECS_API extern ECS_COMPONENT_DECLARE(ecs_entities_memory_t);
420FLECS_API extern ECS_COMPONENT_DECLARE(ecs_component_index_memory_t);
421FLECS_API extern ECS_COMPONENT_DECLARE(ecs_query_memory_t);
422FLECS_API extern ECS_COMPONENT_DECLARE(ecs_component_memory_t);
423FLECS_API extern ECS_COMPONENT_DECLARE(ecs_table_memory_t);
424FLECS_API extern ECS_COMPONENT_DECLARE(ecs_misc_memory_t);
425FLECS_API extern ECS_COMPONENT_DECLARE(ecs_table_histogram_t);
426FLECS_API extern ECS_COMPONENT_DECLARE(ecs_allocator_memory_t);
427FLECS_API extern ECS_COMPONENT_DECLARE(EcsWorldMemory);
428
429FLECS_API extern ecs_entity_t EcsPeriod1s;
430FLECS_API extern ecs_entity_t EcsPeriod1m;
431FLECS_API extern ecs_entity_t EcsPeriod1h;
432FLECS_API extern ecs_entity_t EcsPeriod1d;
433FLECS_API extern ecs_entity_t EcsPeriod1w;
434
436 typedef struct {
437 ecs_ftime_t elapsed;
438 int32_t reduce_count;
439} EcsStatsHeader;
440
442 typedef struct {
443 EcsStatsHeader hdr;
444 ecs_world_stats_t *stats;
445} EcsWorldStats;
446
448 typedef struct {
449 EcsStatsHeader hdr;
450 ecs_map_t stats;
451} EcsSystemStats;
452
454 typedef struct {
455 EcsStatsHeader hdr;
456 ecs_map_t stats;
457} EcsPipelineStats;
458
460 typedef struct {
461 /* Time */
462 double target_fps;
463 double time_scale;
464 double fps;
465
466 /* Totals */
467 double frame_time_total;
468 double system_time_total;
469 double merge_time_total;
470
471 int64_t entity_count;
472 int64_t table_count;
473 int64_t frame_count;
474 int64_t command_count;
475 int64_t merge_count;
476
477 int64_t systems_ran_total;
478 int64_t observers_ran_total;
479 int64_t queries_ran_total;
480
481 int32_t tag_count;
482 int32_t component_count;
483 int32_t pair_count;
484
485 /* Per frame */
486 double frame_time_frame;
487 double system_time_frame;
488 double merge_time_frame;
489
490 int64_t merge_count_frame;
491 int64_t systems_ran_frame;
492 int64_t observers_ran_frame;
493 int64_t queries_ran_frame;
494 int64_t command_count_frame;
495
496 double simulation_time;
497 uint32_t uptime;
498
499 /* Build info */
500 ecs_build_info_t build_info;
501} EcsWorldSummary;
502
504 typedef struct {
505 int32_t alive_count;
506 int32_t not_alive_count;
507 ecs_size_t bytes_entity_index;
508 ecs_size_t bytes_names;
509 ecs_size_t bytes_doc_strings;
510} ecs_entities_memory_t;
511
512/* Component memory. */
513 typedef struct {
514 int32_t instances;
515 ecs_size_t bytes_table_components;
516 ecs_size_t bytes_table_components_unused;
517 ecs_size_t bytes_toggle_bitsets;
518 ecs_size_t bytes_sparse_components;
519} ecs_component_memory_t;
520
522 typedef struct {
523 int32_t count;
524 ecs_size_t bytes_component_record;
525 ecs_size_t bytes_table_cache;
526 ecs_size_t bytes_name_index;
527 ecs_size_t bytes_ordered_children;
528 ecs_size_t bytes_reachable_cache;
529} ecs_component_index_memory_t;
530
532 typedef struct {
533 int32_t count;
534 int32_t cached_count;
535 ecs_size_t bytes_query;
536 ecs_size_t bytes_cache;
537 ecs_size_t bytes_group_by;
538 ecs_size_t bytes_order_by;
539 ecs_size_t bytes_plan;
540 ecs_size_t bytes_terms;
541 ecs_size_t bytes_misc;
542} ecs_query_memory_t;
543
545#define ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT 14
546#define ECS_TABLE_MEMORY_HISTOGRAM_MAX_COUNT (1 << ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT)
547
549 typedef struct {
550 int32_t count;
551 int32_t empty_count;
552 int32_t column_count;
553 ecs_size_t bytes_table;
554 ecs_size_t bytes_type;
555 ecs_size_t bytes_entities;
556 ecs_size_t bytes_overrides;
557 ecs_size_t bytes_columns;
558 ecs_size_t bytes_table_records;
559 ecs_size_t bytes_column_map;
560 ecs_size_t bytes_component_map;
561 ecs_size_t bytes_dirty_state;
562 ecs_size_t bytes_edges;
563} ecs_table_memory_t;
564
566 typedef struct {
567 int32_t entity_counts[ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT];
568} ecs_table_histogram_t;
569
571 typedef struct {
572 ecs_size_t bytes_world;
573 ecs_size_t bytes_observers;
574 ecs_size_t bytes_systems;
575 ecs_size_t bytes_pipelines;
576 ecs_size_t bytes_table_lookup;
577 ecs_size_t bytes_component_record_lookup;
578 ecs_size_t bytes_type_info;
579 ecs_size_t bytes_commands;
580 ecs_size_t bytes_rematch_monitor;
581 ecs_size_t bytes_component_ids;
582 ecs_size_t bytes_reflection;
583 ecs_size_t bytes_stats;
584 ecs_size_t bytes_rest;
585} ecs_misc_memory_t;
586
589 typedef struct {
590 ecs_size_t bytes_graph_edge;
591 ecs_size_t bytes_component_record;
592 ecs_size_t bytes_pair_record;
593 ecs_size_t bytes_table_diff;
594 ecs_size_t bytes_sparse_chunk;
595 ecs_size_t bytes_allocator;
596 ecs_size_t bytes_stack_allocator;
597 ecs_size_t bytes_cmd_entry_chunk;
598 ecs_size_t bytes_query_impl;
599 ecs_size_t bytes_query_cache;
600 ecs_size_t bytes_misc;
601} ecs_allocator_memory_t;
602
604 typedef struct {
605 ecs_entities_memory_t entities;
606 ecs_component_memory_t components;
607 ecs_component_index_memory_t component_index;
608 ecs_query_memory_t queries;
609 ecs_table_memory_t tables;
610 ecs_table_histogram_t table_histogram;
611 ecs_misc_memory_t misc;
612 ecs_allocator_memory_t allocators;
613 double collection_time;
614} EcsWorldMemory;
615
622FLECS_API
623 ecs_entities_memory_t ecs_entity_memory_get(
624 const ecs_world_t *world);
625
631 void ecs_component_record_memory_get(
632 const ecs_component_record_t *cr,
633 ecs_component_index_memory_t *result);
634
640FLECS_API
641 ecs_component_index_memory_t ecs_component_index_memory_get(
642 const ecs_world_t *world);
643
649FLECS_API
650 void ecs_query_memory_get(
651 const ecs_query_t *query,
652 ecs_query_memory_t *result);
653
659FLECS_API
660 ecs_query_memory_t ecs_queries_memory_get(
661 const ecs_world_t *world);
662
668 void ecs_table_component_memory_get(
669 const ecs_table_t *table,
670 ecs_component_memory_t *result);
671
677FLECS_API
678 ecs_component_memory_t ecs_component_memory_get(
679 const ecs_world_t *world);
680
686 void ecs_table_memory_get(
687 const ecs_table_t *table,
688 ecs_table_memory_t *result);
689
695FLECS_API
696 ecs_table_memory_t ecs_tables_memory_get(
697 const ecs_world_t *world);
698
704FLECS_API
705 ecs_table_histogram_t ecs_table_histogram_get(
706 const ecs_world_t *world);
707
713FLECS_API
714 ecs_misc_memory_t ecs_misc_memory_get(
715 const ecs_world_t *world);
716
722FLECS_API
723 ecs_allocator_memory_t ecs_allocator_memory_get(
724 const ecs_world_t *world);
725
730FLECS_API
731ecs_size_t ecs_memory_get(
732 const ecs_world_t *world);
733
734
743FLECS_API
744 void FlecsStatsImport(
745 ecs_world_t *world);
746
747#ifdef __cplusplus
748}
749#endif
750
751#endif
752
754
755#endif
ecs_memory_get
FLECS_API ecs_size_t ecs_memory_get(const ecs_world_t *world)
Get total memory used by world.
ecs_world_stats_reduce
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.
ecs_query_stats_get
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.
ecs_query_cache_stats_reduce_last
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.
ecs_world_stats_get
FLECS_API void ecs_world_stats_get(const ecs_world_t *world, ecs_world_stats_t *stats)
Get world statistics.
EcsPeriod1s
FLECS_API ecs_entity_t EcsPeriod1s
Tag used for metrics collected in last second.
ecs_queries_memory_get
FLECS_API ecs_query_memory_t ecs_queries_memory_get(const ecs_world_t *world)
Get memory usage statistics for queries.
ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT
#define ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT
Table memory histogram constants.
Definition stats.h:545
EcsPeriod1h
FLECS_API ecs_entity_t EcsPeriod1h
Tag used for metrics collected in last hour.
ecs_pipeline_stats_reduce_last
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.
ecs_component_memory_get
FLECS_API ecs_component_memory_t ecs_component_memory_get(const ecs_world_t *world)
Get memory usage statistics for components.
ecs_misc_memory_get
FLECS_API ecs_misc_memory_t ecs_misc_memory_get(const ecs_world_t *world)
Get memory usage statistics for commands.
ecs_query_cache_stats_repeat_last
FLECS_API void ecs_query_cache_stats_repeat_last(ecs_query_stats_t *stats)
Repeat last measurement.
ecs_metric_reduce_last
FLECS_API void ecs_metric_reduce_last(ecs_metric_t *m, int32_t t, int32_t count)
Reduce last measurement into previous measurement.
ecs_system_stats_get
FLECS_API bool ecs_system_stats_get(const ecs_world_t *world, ecs_entity_t system, ecs_system_stats_t *stats)
Get system statistics.
ecs_world_stats_reduce_last
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.
ecs_allocator_memory_get
FLECS_API ecs_allocator_memory_t ecs_allocator_memory_get(const ecs_world_t *world)
Get memory usage statistics for allocators.
ecs_table_histogram_get
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.
ecs_query_cache_stats_reduce
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.
ecs_query_memory_get
FLECS_API void ecs_query_memory_get(const ecs_query_t *query, ecs_query_memory_t *result)
Get memory usage statistics for single query.
FlecsStatsImport
FLECS_API void FlecsStatsImport(ecs_world_t *world)
Stats module import function.
ecs_metric_copy
FLECS_API void ecs_metric_copy(ecs_metric_t *m, int32_t dst, int32_t src)
Copy measurement.
ecs_entity_memory_get
FLECS_API ecs_entities_memory_t ecs_entity_memory_get(const ecs_world_t *world)
Memory statistics getters.
ecs_pipeline_stats_repeat_last
FLECS_API void ecs_pipeline_stats_repeat_last(ecs_pipeline_stats_t *stats)
Repeat last measurement.
ecs_pipeline_stats_fini
FLECS_API void ecs_pipeline_stats_fini(ecs_pipeline_stats_t *stats)
Free pipeline stats.
ecs_pipeline_stats_copy_last
FLECS_API void ecs_pipeline_stats_copy_last(ecs_pipeline_stats_t *dst, const ecs_pipeline_stats_t *src)
Copy last measurement to destination.
ecs_system_stats_reduce
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.
ecs_tables_memory_get
FLECS_API ecs_table_memory_t ecs_tables_memory_get(const ecs_world_t *world)
Get memory usage statistics for tables.
ecs_pipeline_stats_reduce
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.
ecs_system_stats_copy_last
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.
ecs_system_stats_repeat_last
FLECS_API void ecs_system_stats_repeat_last(ecs_system_stats_t *stats)
Repeat last measurement.
ecs_table_component_memory_get
void ecs_table_component_memory_get(const ecs_table_t *table, ecs_component_memory_t *result)
Get component memory for table.
ecs_world_stats_repeat_last
FLECS_API void ecs_world_stats_repeat_last(ecs_world_stats_t *stats)
Repeat last measurement.
ecs_world_stats_copy_last
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.
ecs_metric_reduce
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.
EcsPeriod1m
FLECS_API ecs_entity_t EcsPeriod1m
Tag used for metrics collected in last minute.
ecs_pipeline_stats_get
FLECS_API bool ecs_pipeline_stats_get(ecs_world_t *world, ecs_entity_t pipeline, ecs_pipeline_stats_t *stats)
Get pipeline statistics.
EcsPeriod1w
FLECS_API ecs_entity_t EcsPeriod1w
Tag used for metrics collected in last week.
ecs_component_record_memory_get
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.
ecs_system_stats_reduce_last
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.
EcsPeriod1d
FLECS_API ecs_entity_t EcsPeriod1d
Tag used for metrics collected in last day.
ecs_table_memory_get
void ecs_table_memory_get(const ecs_table_t *table, ecs_table_memory_t *result)
Get memory usage statistics for single table.
ecs_component_index_memory_get
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.
ecs_query_cache_stats_copy_last
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.
ecs_component_record_t
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:473
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:361
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:405
ecs_table_t
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:411
ECS_COMPONENT_DECLARE
#define ECS_COMPONENT_DECLARE(id)
Forward declare a component.
Definition flecs_c.h:112
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
ecs_float_t
#define ecs_float_t
Customizable precision for floating point operations.
Definition flecs.h:52
EcsPipelineStats
Component that stores pipeline statistics.
Definition stats.h:454
EcsStatsHeader
Common data for statistics.
Definition stats.h:436
EcsSystemStats
Component that stores system statistics.
Definition stats.h:448
EcsWorldMemory
Component with memory statistics.
Definition stats.h:604
EcsWorldStats
Component that stores world statistics.
Definition stats.h:442
EcsWorldSummary
Component that stores a summary of world statistics.
Definition stats.h:460
EcsWorldSummary::component_count
int32_t component_count
Number of component (data) ids in the world.
Definition stats.h:482
EcsWorldSummary::frame_time_frame
double frame_time_frame
Time spent processing a frame.
Definition stats.h:486
EcsWorldSummary::simulation_time
double simulation_time
Time spent in simulation.
Definition stats.h:496
EcsWorldSummary::target_fps
double target_fps
Target FPS.
Definition stats.h:462
EcsWorldSummary::merge_time_total
double merge_time_total
Total time spent in merges.
Definition stats.h:469
EcsWorldSummary::system_time_frame
double system_time_frame
Time spent in systems.
Definition stats.h:487
EcsWorldSummary::frame_count
int64_t frame_count
Number of frames processed.
Definition stats.h:473
EcsWorldSummary::pair_count
int32_t pair_count
Number of pair ids in the world.
Definition stats.h:483
EcsWorldSummary::build_info
ecs_build_info_t build_info
Build info.
Definition stats.h:500
EcsWorldSummary::merge_count
int64_t merge_count
Number of merges executed.
Definition stats.h:475
EcsWorldSummary::command_count_frame
int64_t command_count_frame
Number of commands processed in last frame.
Definition stats.h:494
EcsWorldSummary::system_time_total
double system_time_total
Total time spent in systems.
Definition stats.h:468
EcsWorldSummary::uptime
uint32_t uptime
Time since world was created.
Definition stats.h:497
EcsWorldSummary::merge_time_frame
double merge_time_frame
Time spent in merges.
Definition stats.h:488
EcsWorldSummary::frame_time_total
double frame_time_total
Total time spent processing a frame.
Definition stats.h:467
EcsWorldSummary::tag_count
int32_t tag_count
Number of tag (no data) ids in the world.
Definition stats.h:481
EcsWorldSummary::time_scale
double time_scale
Simulation time scale.
Definition stats.h:463
EcsWorldSummary::fps
double fps
FPS.
Definition stats.h:464
EcsWorldSummary::command_count
int64_t command_count
Number of commands processed.
Definition stats.h:474
ecs_allocator_memory_t
Allocator memory.
Definition stats.h:589
ecs_allocator_memory_t::bytes_sparse_chunk
ecs_size_t bytes_sparse_chunk
Table diff allocator.
Definition stats.h:594
ecs_allocator_memory_t::bytes_table_diff
ecs_size_t bytes_table_diff
Pair record allocator.
Definition stats.h:593
ecs_allocator_memory_t::bytes_query_impl
ecs_size_t bytes_query_impl
Command batching entry chunk allocator.
Definition stats.h:598
ecs_allocator_memory_t::bytes_allocator
ecs_size_t bytes_allocator
Sparse chunk allocator.
Definition stats.h:595
ecs_allocator_memory_t::bytes_stack_allocator
ecs_size_t bytes_stack_allocator
Generic allocator.
Definition stats.h:596
ecs_allocator_memory_t::bytes_cmd_entry_chunk
ecs_size_t bytes_cmd_entry_chunk
Stack allocator.
Definition stats.h:597
ecs_allocator_memory_t::bytes_misc
ecs_size_t bytes_misc
Query cache struct allocator.
Definition stats.h:600
ecs_allocator_memory_t::bytes_pair_record
ecs_size_t bytes_pair_record
Component record allocator.
Definition stats.h:592
ecs_allocator_memory_t::bytes_query_cache
ecs_size_t bytes_query_cache
Query struct allocator.
Definition stats.h:599
ecs_allocator_memory_t::bytes_component_record
ecs_size_t bytes_component_record
Graph edge allocator.
Definition stats.h:591
ecs_build_info_t
Type with information about the current Flecs build.
Definition flecs.h:1435
ecs_component_index_memory_t
Component index memory.
Definition stats.h:522
ecs_component_index_memory_t::bytes_component_record
ecs_size_t bytes_component_record
Number of component records.
Definition stats.h:524
ecs_component_index_memory_t::bytes_ordered_children
ecs_size_t bytes_ordered_children
Bytes used by name index.
Definition stats.h:527
ecs_component_index_memory_t::bytes_table_cache
ecs_size_t bytes_table_cache
Bytes used by ecs_component_record_t struct.
Definition stats.h:525
ecs_component_index_memory_t::bytes_name_index
ecs_size_t bytes_name_index
Bytes used by table cache.
Definition stats.h:526
ecs_component_index_memory_t::bytes_reachable_cache
ecs_size_t bytes_reachable_cache
Bytes used by ordered children vector.
Definition stats.h:528
ecs_component_memory_t
Definition stats.h:513
ecs_component_memory_t::bytes_sparse_components
ecs_size_t bytes_sparse_components
Bytes used in bitsets (toggled components).
Definition stats.h:518
ecs_component_memory_t::bytes_table_components_unused
ecs_size_t bytes_table_components_unused
Bytes used by table columns.
Definition stats.h:516
ecs_component_memory_t::bytes_table_components
ecs_size_t bytes_table_components
Total number of component instances.
Definition stats.h:515
ecs_component_memory_t::bytes_toggle_bitsets
ecs_size_t bytes_toggle_bitsets
Unused bytes in table columns.
Definition stats.h:517
ecs_counter_t
Monotonically increasing counter.
Definition stats.h:50
ecs_counter_t::rate
ecs_gauge_t rate
Keep track of deltas too.
Definition stats.h:51
ecs_entities_memory_t
Entity memory.
Definition stats.h:504
ecs_entities_memory_t::not_alive_count
int32_t not_alive_count
Number of alive entities.
Definition stats.h:506
ecs_entities_memory_t::bytes_doc_strings
ecs_size_t bytes_doc_strings
Bytes used by names, symbols, aliases.
Definition stats.h:509
ecs_entities_memory_t::bytes_entity_index
ecs_size_t bytes_entity_index
Number of not alive entities.
Definition stats.h:507
ecs_entities_memory_t::bytes_names
ecs_size_t bytes_names
Bytes used by entity index.
Definition stats.h:508
ecs_gauge_t
Simple value that indicates current state.
Definition stats.h:43
ecs_misc_memory_t
Misc memory.
Definition stats.h:571
ecs_misc_memory_t::bytes_component_ids
ecs_size_t bytes_component_ids
Memory used by monitor used to track rematches.
Definition stats.h:581
ecs_misc_memory_t::bytes_observers
ecs_size_t bytes_observers
Memory used by world and stages.
Definition stats.h:573
ecs_misc_memory_t::bytes_type_info
ecs_size_t bytes_type_info
Bytes used for component record lookup data structures.
Definition stats.h:578
ecs_misc_memory_t::bytes_reflection
ecs_size_t bytes_reflection
Memory used for mapping global to world-local component ids.
Definition stats.h:582
ecs_misc_memory_t::bytes_stats
ecs_size_t bytes_stats
Memory used for component reflection not tracked elsewhere.
Definition stats.h:583
ecs_misc_memory_t::bytes_systems
ecs_size_t bytes_systems
Memory used by observers.
Definition stats.h:574
ecs_misc_memory_t::bytes_pipelines
ecs_size_t bytes_pipelines
Memory used by systems (excluding system queries).
Definition stats.h:575
ecs_misc_memory_t::bytes_rematch_monitor
ecs_size_t bytes_rematch_monitor
Command queue.
Definition stats.h:580
ecs_misc_memory_t::bytes_rest
ecs_size_t bytes_rest
Memory used for statistics tracking not tracked elsewhere.
Definition stats.h:584
ecs_misc_memory_t::bytes_commands
ecs_size_t bytes_commands
Bytes used for storing type information.
Definition stats.h:579
ecs_misc_memory_t::bytes_component_record_lookup
ecs_size_t bytes_component_record_lookup
Bytes used for table lookup data structures.
Definition stats.h:577
ecs_misc_memory_t::bytes_table_lookup
ecs_size_t bytes_table_lookup
Memory used by pipelines (excluding pipeline queries).
Definition stats.h:576
ecs_pipeline_stats_t
Statistics for all systems in a pipeline.
Definition stats.h:205
ecs_pipeline_stats_t::rebuild_count
int32_t rebuild_count
Number of times pipeline has rebuilt.
Definition stats.h:221
ecs_pipeline_stats_t::system_count
int32_t system_count
Number of systems in pipeline.
Definition stats.h:219
ecs_pipeline_stats_t::systems
ecs_vec_t systems
Vector with system ids of all systems in the pipeline.
Definition stats.h:211
ecs_pipeline_stats_t::active_system_count
int32_t active_system_count
Number of active systems in pipeline.
Definition stats.h:220
ecs_pipeline_stats_t::sync_points
ecs_vec_t sync_points
Vector with sync point stats.
Definition stats.h:214
ecs_pipeline_stats_t::t
int32_t t
Current position in ring buffer.
Definition stats.h:217
ecs_query_memory_t
Query memory.
Definition stats.h:532
ecs_query_memory_t::bytes_cache
ecs_size_t bytes_cache
Bytes used by ecs_query_impl_t struct.
Definition stats.h:536
ecs_query_memory_t::bytes_terms
ecs_size_t bytes_terms
Bytes used by query plan.
Definition stats.h:540
ecs_query_memory_t::bytes_order_by
ecs_size_t bytes_order_by
Bytes used by query cache groups (excludes cache elements).
Definition stats.h:538
ecs_query_memory_t::cached_count
int32_t cached_count
Number of queries.
Definition stats.h:534
ecs_query_memory_t::bytes_query
ecs_size_t bytes_query
Number of queries with caches.
Definition stats.h:535
ecs_query_memory_t::bytes_misc
ecs_size_t bytes_misc
Bytes used by terms array.
Definition stats.h:541
ecs_query_memory_t::bytes_group_by
ecs_size_t bytes_group_by
Bytes used by query cache.
Definition stats.h:537
ecs_query_memory_t::bytes_plan
ecs_size_t bytes_plan
Bytes used by table_slices.
Definition stats.h:539
ecs_query_stats_t
Statistics for a single query (use ecs_query_cache_stats_get)
Definition stats.h:170
ecs_query_stats_t::result_count
ecs_metric_t result_count
Number of query results.
Definition stats.h:172
ecs_query_stats_t::t
int32_t t
Current position in ringbuffer.
Definition stats.h:178
ecs_query_stats_t::matched_table_count
ecs_metric_t matched_table_count
Number of matched tables.
Definition stats.h:173
ecs_query_stats_t::matched_entity_count
ecs_metric_t matched_entity_count
Number of matched entities.
Definition stats.h:174
ecs_query_t
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:813
ecs_sync_stats_t
Statistics for sync point.
Definition stats.h:193
ecs_system_stats_t
Statistics for a single system (use ecs_system_stats_get())
Definition stats.h:182
ecs_system_stats_t::task
bool task
Is system a task.
Definition stats.h:187
ecs_system_stats_t::time_spent
ecs_metric_t time_spent
Time spent processing a system.
Definition stats.h:184
ecs_table_histogram_t
Table size histogram.
Definition stats.h:566
ecs_table_memory_t
Table memory.
Definition stats.h:549
ecs_table_memory_t::bytes_dirty_state
ecs_size_t bytes_dirty_state
Bytes used by component map.
Definition stats.h:561
ecs_table_memory_t::bytes_type
ecs_size_t bytes_type
Bytes used by ecs_table_t struct.
Definition stats.h:554
ecs_table_memory_t::bytes_edges
ecs_size_t bytes_edges
Bytes used by dirty state.
Definition stats.h:562
ecs_table_memory_t::bytes_table
ecs_size_t bytes_table
Number of table columns.
Definition stats.h:553
ecs_table_memory_t::column_count
int32_t column_count
Number of empty tables.
Definition stats.h:552
ecs_table_memory_t::bytes_overrides
ecs_size_t bytes_overrides
Bytes used by entity vectors.
Definition stats.h:556
ecs_table_memory_t::bytes_columns
ecs_size_t bytes_columns
Bytes used by table overrides.
Definition stats.h:557
ecs_table_memory_t::bytes_table_records
ecs_size_t bytes_table_records
Bytes used by table columns (excluding component data).
Definition stats.h:558
ecs_table_memory_t::bytes_component_map
ecs_size_t bytes_component_map
Bytes used by column map.
Definition stats.h:560
ecs_table_memory_t::empty_count
int32_t empty_count
Total number of tables.
Definition stats.h:551
ecs_table_memory_t::bytes_entities
ecs_size_t bytes_entities
Bytes used by type vector.
Definition stats.h:555
ecs_table_memory_t::bytes_column_map
ecs_size_t bytes_column_map
Bytes used by table records.
Definition stats.h:559
ecs_world_stats_t
Definition stats.h:61
ecs_world_stats_t::alloc_count
ecs_metric_t alloc_count
Allocs per frame.
Definition stats.h:136
ecs_world_stats_t::block_free_count
ecs_metric_t block_free_count
Block frees per frame.
Definition stats.h:143
ecs_world_stats_t::system_time
ecs_metric_t system_time
Time spent on running systems.
Definition stats.h:126
ecs_world_stats_t::world_time_raw
ecs_metric_t world_time_raw
Actual time passed since simulation start (first time progress() is called)
Definition stats.h:123
ecs_world_stats_t::delete_count
ecs_metric_t delete_count
Number of times id has been deleted.
Definition stats.h:77
ecs_world_stats_t::rematch_count
ecs_metric_t rematch_count
Number of query rematches.
Definition stats.h:114
ecs_world_stats_t::frame_time
ecs_metric_t frame_time
Time spent processing a frame.
Definition stats.h:125
ecs_world_stats_t::tag_count
ecs_metric_t tag_count
Number of tag ids (ids without data)
Definition stats.h:72
ecs_world_stats_t::component_count
ecs_metric_t component_count
Number of components ids (ids with data)
Definition stats.h:73
ecs_world_stats_t::system_count
ecs_metric_t system_count
Number of systems.
Definition stats.h:92
ecs_world_stats_t::merge_count
ecs_metric_t merge_count
Number of merges executed.
Definition stats.h:113
ecs_world_stats_t::free_count
ecs_metric_t free_count
Frees per frame.
Definition stats.h:138
ecs_world_stats_t::query_count
ecs_metric_t query_count
Number of queries.
Definition stats.h:90
ecs_world_stats_t::world_time
ecs_metric_t world_time
Simulation time passed since simulation start.
Definition stats.h:124
ecs_world_stats_t::realloc_count
ecs_metric_t realloc_count
Reallocs per frame.
Definition stats.h:137
ecs_world_stats_t::merge_time
ecs_metric_t merge_time
Time spent on merging commands.
Definition stats.h:128
ecs_world_stats_t::outstanding_alloc_count
ecs_metric_t outstanding_alloc_count
Difference between allocs & frees.
Definition stats.h:139
ecs_world_stats_t::observers_ran
ecs_metric_t observers_ran
Number of times an observer was invoked.
Definition stats.h:117
ecs_world_stats_t::frame_count
ecs_metric_t frame_count
Number of frames processed.
Definition stats.h:112
ecs_world_stats_t::event_emit_count
ecs_metric_t event_emit_count
Number of events emitted.
Definition stats.h:118
ecs_world_stats_t::empty_count
ecs_metric_t empty_count
Number of empty tables.
Definition stats.h:83
ecs_world_stats_t::block_outstanding_alloc_count
ecs_metric_t block_outstanding_alloc_count
Difference between allocs & frees.
Definition stats.h:144
ecs_world_stats_t::t
int32_t t
Current position in ring buffer.
Definition stats.h:166
ecs_world_stats_t::stack_free_count
ecs_metric_t stack_free_count
Page frees per frame.
Definition stats.h:146
ecs_world_stats_t::rematch_time
ecs_metric_t rematch_time
Time spent on rematching.
Definition stats.h:129
ecs_world_stats_t::fps
ecs_metric_t fps
Frames per second.
Definition stats.h:130
ecs_world_stats_t::systems_ran
ecs_metric_t systems_ran
Number of systems ran.
Definition stats.h:116
ecs_world_stats_t::type_count
ecs_metric_t type_count
Number of registered types.
Definition stats.h:75
ecs_world_stats_t::count
ecs_metric_t count
Number of entities.
Definition stats.h:66
ecs_world_stats_t::emit_time
ecs_metric_t emit_time
Time spent on notifying observers.
Definition stats.h:127
ecs_world_stats_t::create_count
ecs_metric_t create_count
Number of times id has been created.
Definition stats.h:76
ecs_world_stats_t::not_alive_count
ecs_metric_t not_alive_count
Number of not alive (recyclable) entity ids.
Definition stats.h:67
ecs_world_stats_t::stack_alloc_count
ecs_metric_t stack_alloc_count
Page allocations per frame.
Definition stats.h:145
ecs_world_stats_t::observer_count
ecs_metric_t observer_count
Number of observers.
Definition stats.h:91
ecs_world_stats_t::pipeline_build_count
ecs_metric_t pipeline_build_count
Number of system pipeline rebuilds (occurs when an inactive system becomes active).
Definition stats.h:115
ecs_world_stats_t::stack_outstanding_alloc_count
ecs_metric_t stack_outstanding_alloc_count
Difference between allocs & frees.
Definition stats.h:147
ecs_world_stats_t::block_alloc_count
ecs_metric_t block_alloc_count
Block allocations per frame.
Definition stats.h:142
ecs_world_stats_t::delta_time
ecs_metric_t delta_time
Delta_time.
Definition stats.h:131
ecs_world_stats_t::pair_count
ecs_metric_t pair_count
Number of pair ids.
Definition stats.h:74
ecs_metric_t
Make all metrics the same size, so we can iterate over fields.
Definition stats.h:56