Flecs: Stats
Description: A fast entity component system (ECS) for C & C++

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

Loading...
Searching...
No Matches
Stats
C API » Addons

Collection of statistics for world, queries, systems, and pipelines. More...

Collaboration diagram for Stats:

## Classes
struct | ecs_gauge_t
| Simple value that indicates current state. More...
struct | ecs_counter_t
| Monotonically increasing counter. More...
union | ecs_metric_t
| Make all metrics the same size, so we can iterate over fields. More...
struct | ecs_world_stats_t
| Type that contains world statistics. More...
struct | ecs_query_stats_t
| Statistics for a single query (use ecs_query_cache_stats_get()). More...
struct | ecs_system_stats_t
| Statistics for a single system (use ecs_system_stats_get()). More...
struct | ecs_sync_stats_t
| Statistics for sync point. More...
struct | ecs_pipeline_stats_t
| Statistics for all systems in a pipeline. More...
struct | EcsStatsHeader
| Common header for statistics types. More...
struct | EcsWorldStats
| Component that stores world statistics. More...
struct | EcsSystemStats
| Component that stores system statistics. More...
struct | EcsPipelineStats
| Component that stores pipeline statistics. More...
struct | EcsWorldSummary
| Component that stores a summary of world statistics. More...
struct | ecs_entities_memory_t
| Entity memory. More...
struct | ecs_component_memory_t
| Component memory. More...
struct | ecs_component_index_memory_t
| Component index memory. More...
struct | ecs_query_memory_t
| Query memory. More...
struct | ecs_table_memory_t
| Table memory. More...
struct | ecs_table_histogram_t
| Table size histogram. More...
struct | ecs_misc_memory_t
| Misc memory. More...
struct | ecs_allocator_memory_t
| Allocator memory. More...
struct | EcsWorldMemory
| Component with memory statistics. More...

## Macros
#define | ECS_STAT_WINDOW (60)
| Number of samples in the stat window.
#define | ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT 14
| Table memory histogram constants.
#define | ECS_TABLE_MEMORY_HISTOGRAM_MAX_COUNT (1 << ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT)

## Typedefs
typedef struct ecs_gauge_t | ecs_gauge_t
| Simple value that indicates current state.
typedef struct ecs_counter_t | ecs_counter_t
| Monotonically increasing counter.
typedef union ecs_metric_t | ecs_metric_t
| Make all metrics the same size, so we can iterate over fields.
typedef struct ecs_world_stats_t | ecs_world_stats_t
| Type that contains world statistics.
typedef struct ecs_query_stats_t | ecs_query_stats_t
| Statistics for a single query (use ecs_query_cache_stats_get()).
typedef struct ecs_system_stats_t | ecs_system_stats_t
| Statistics for a single system (use ecs_system_stats_get()).
typedef struct ecs_sync_stats_t | ecs_sync_stats_t
| Statistics for sync point.
typedef struct ecs_pipeline_stats_t | ecs_pipeline_stats_t
| Statistics for all systems in a pipeline.

## Functions
FLECS_API void | ecs_world_stats_get (const ecs_world_t *world, ecs_world_stats_t *stats)
| Get world statistics.
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_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 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_world_stats_log (const ecs_world_t *world, const ecs_world_stats_t *stats)
| Log world statistics.
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 (ecs_query_stats_t *dst, const ecs_query_stats_t *src)
| Reduce source measurement window into single destination measurement.
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_query_cache_stats_repeat_last (ecs_query_stats_t *stats)
| Repeat last measurement.
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.
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_system_stats_reduce (ecs_system_stats_t *dst, const ecs_system_stats_t *src)
| Reduce source measurement window into single destination measurement.
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_system_stats_repeat_last (ecs_system_stats_t *stats)
| Repeat last 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 bool | ecs_pipeline_stats_get (ecs_world_t *world, ecs_entity_t pipeline, ecs_pipeline_stats_t *stats)
| Get pipeline statistics.
FLECS_API void | ecs_pipeline_stats_fini (ecs_pipeline_stats_t *stats)
| Free pipeline stats.
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_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 void | ecs_pipeline_stats_repeat_last (ecs_pipeline_stats_t *stats)
| Repeat last measurement.
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_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 void | ecs_metric_reduce_last (ecs_metric_t *m, int32_t t, int32_t count)
| Reduce last measurement into previous measurement.
FLECS_API void | ecs_metric_copy (ecs_metric_t *m, int32_t dst, int32_t src)
| Copy measurement.
FLECS_API | ECS_COMPONENT_DECLARE (FlecsStats)
| Flecs stats module.
FLECS_API | ECS_COMPONENT_DECLARE (EcsWorldStats)
| Component ID for EcsWorldStats.
FLECS_API | ECS_COMPONENT_DECLARE (EcsWorldSummary)
| Component ID for EcsWorldSummary.
FLECS_API | ECS_COMPONENT_DECLARE (EcsSystemStats)
| Component ID for EcsSystemStats.
FLECS_API | ECS_COMPONENT_DECLARE (EcsPipelineStats)
| Component ID for EcsPipelineStats.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_entities_memory_t)
| Component ID for ecs_entities_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_component_index_memory_t)
| Component ID for ecs_component_index_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_query_memory_t)
| Component ID for ecs_query_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_component_memory_t)
| Component ID for ecs_component_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_table_memory_t)
| Component ID for ecs_table_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_misc_memory_t)
| Component ID for ecs_misc_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_table_histogram_t)
| Component ID for ecs_table_histogram_t.
FLECS_API | ECS_COMPONENT_DECLARE (ecs_allocator_memory_t)
| Component ID for ecs_allocator_memory_t.
FLECS_API | ECS_COMPONENT_DECLARE (EcsWorldMemory)
| Component ID for EcsWorldMemory.
FLECS_API ecs_entities_memory_t | ecs_entity_memory_get (const ecs_world_t *world)
| Get memory usage statistics for the entity index.
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 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_memory_get (const ecs_query_t *query, ecs_query_memory_t *result)
| Get memory usage statistics for single query.
FLECS_API ecs_query_memory_t | ecs_queries_memory_get (const ecs_world_t *world)
| Get memory usage statistics for queries.
void | ecs_table_component_memory_get (const ecs_table_t *table, ecs_component_memory_t *result)
| Get component memory for table.
FLECS_API ecs_component_memory_t | ecs_component_memory_get (const ecs_world_t *world)
| Get memory usage statistics for components.
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_table_memory_t | ecs_tables_memory_get (const ecs_world_t *world)
| Get memory usage statistics for tables.
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 ecs_misc_memory_t | ecs_misc_memory_get (const ecs_world_t *world)
| Get memory usage statistics for miscellaneous allocations.
FLECS_API ecs_allocator_memory_t | ecs_allocator_memory_get (const ecs_world_t *world)
| Get memory usage statistics for allocators.
FLECS_API ecs_size_t | ecs_memory_get (const ecs_world_t *world)
| Get total memory used by world.
FLECS_API void | FlecsStatsImport (ecs_world_t *world)
| Stats module import function.

## Variables
FLECS_API ecs_entity_t | EcsPeriod1s
| Tag used for metrics collected in last second.
FLECS_API ecs_entity_t | EcsPeriod1m
| Tag used for metrics collected in last minute.
FLECS_API ecs_entity_t | EcsPeriod1h
| Tag used for metrics collected in last hour.
FLECS_API ecs_entity_t | EcsPeriod1d
| Tag used for metrics collected in last day.
FLECS_API ecs_entity_t | EcsPeriod1w
| Tag used for metrics collected in last week.

## Detailed Description

Collection of statistics for world, queries, systems, and pipelines.

## Macro Definition Documentation

## ◆ ECS_STAT_WINDOW

#define ECS_STAT_WINDOW (60)

Number of samples in the stat window.

Definition at line 41 of file stats.h.

## ◆ ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT

#define ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT 14

Table memory histogram constants.

Definition at line 552 of file stats.h.

## ◆ ECS_TABLE_MEMORY_HISTOGRAM_MAX_COUNT

#define ECS_TABLE_MEMORY_HISTOGRAM_MAX_COUNT (1 << ECS_TABLE_MEMORY_HISTOGRAM_BUCKET_COUNT)

Definition at line 553 of file stats.h.

## Function Documentation

## ◆ 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.

Parameters

  world | The world.

Returns
  Memory statistics for allocators.

## ◆ 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.

Parameters

  world | The world.

Returns
  Memory statistics for the component index.

## ◆ 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.

Parameters

  world | The world.

Returns
  Memory statistics for components.

## ◆ 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.

Parameters

  cr | The component record.
  result | Memory statistics for component record (out).

## ◆ ecs_entity_memory_get()

FLECS_API ecs_entities_memory_t ecs_entity_memory_get | ( | const ecs_world_t * | world | ) |

Get memory usage statistics for the entity index.

Parameters

  world | The world.

Returns
  Memory statistics for the entity index.

## ◆ ecs_memory_get()

FLECS_API ecs_size_t ecs_memory_get | ( | const ecs_world_t * | world | ) |

Get total memory used by world.

Parameters

  world | The world.

Returns
  Total memory used in bytes.

## ◆ ecs_misc_memory_get()

FLECS_API ecs_misc_memory_t ecs_misc_memory_get | ( | const ecs_world_t * | world | ) |

Get memory usage statistics for miscellaneous allocations.

Parameters

  world | The world.

Returns
  Memory statistics for miscellaneous allocations.

## ◆ 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.

This operation copies the last measurement into the destination. It does not modify the cursor.

Parameters

  dst | The metrics.
  src | The metrics to copy.

## ◆ ecs_pipeline_stats_fini()

FLECS_API void ecs_pipeline_stats_fini | ( | ecs_pipeline_stats_t * | stats | ) |

Free pipeline stats.

Parameters

  stats | The stats to free.

## ◆ 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.

Obtain statistics for the provided pipeline.

Parameters

  world | The world.
  pipeline | The pipeline.
  stats | Out parameter for statistics.

Returns
  true if success, false if not a pipeline.

## ◆ 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.

Parameters

  world | The world.

Returns
  Memory statistics for queries.

## ◆ 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.

Parameters

  query | The query.
  result | Memory statistics for query (out).

## ◆ 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.

Obtain statistics for the provided query.

Parameters

  world | The world.
  query | The query.
  stats | Out parameter for statistics.

## ◆ 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.

Obtain statistics for the provided system.

Parameters

  world | The world.
  system | The system.
  stats | Out parameter for statistics.

Returns
  true if success, false if not a system.

## ◆ 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.

Parameters

  table | The table.
  result | The memory used by components stored in this table (out).

## ◆ 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.

Parameters

  world | The world.

Returns
  Number of tables by number of entities in the table.

## ◆ 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.

Parameters

  table | The table.
  result | Memory statistics for table (out).

## ◆ 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.

Parameters

  world | The world.

Returns
  Memory statistics for tables.

## ◆ ecs_world_stats_get()

FLECS_API void ecs_world_stats_get | ( | const ecs_world_t * | world,
|  | ecs_world_stats_t * | stats )

Get world statistics.

Parameters

  world | The world.
  stats | Out parameter for statistics.

## ◆ ecs_world_stats_log()

FLECS_API void ecs_world_stats_log | ( | const ecs_world_t * | world,
|  | const ecs_world_stats_t * | stats )

Log world statistics.

Parameters

  world | The world.
  stats | The statistics to log.

## ◆ FlecsStatsImport()

FLECS_API void FlecsStatsImport | ( | ecs_world_t * | world | ) |

Stats module import function.

Usage:

ECS_IMPORT(world, FlecsStats)
ECS_IMPORT
#define ECS_IMPORT(world, id)
Wrapper around ecs_import().
Definition module.h:125

Parameters

  world | The world.