Skip to content

Commit

Permalink
Fix issue in flecs::stats module when global MatchEmptyTables flag is…
Browse files Browse the repository at this point in the history
… set

Differential Revision: D63355531

Pull Request resolved: #1373
  • Loading branch information
SanderMertens authored Sep 25, 2024
1 parent fe2553c commit 4db1bc1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
4 changes: 4 additions & 0 deletions distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -61781,6 +61781,10 @@ void MonitorStats(ecs_iter_t *it) {

cur = 0;
count = qit.count;
if (!count) {
cur = -1;
continue;
}
} else {
cur ++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/addons/stats/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ void MonitorStats(ecs_iter_t *it) {

cur = 0;
count = qit.count;
if (!count) {
cur = -1;
continue;
}
} else {
cur ++;
}
Expand Down
3 changes: 2 additions & 1 deletion test/addons/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
"get_entity_count",
"get_pipeline_stats_w_task_system",
"get_not_alive_entity_count",
"progress_stats_systems"
"progress_stats_systems",
"progress_stats_systems_w_empty_table_flag"
]
}, {
"id": "Run",
Expand Down
22 changes: 19 additions & 3 deletions test/addons/src/Stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,25 @@ void Stats_progress_stats_systems(void) {

ECS_IMPORT(world, FlecsStats);

// for (int i = 0; i < 60 * 60; i ++) {
// ecs_progress(world, 0.016);
// }
for (int i = 0; i < 60 * 60; i ++) {
ecs_progress(world, 0.016);
}

test_assert(true); // used to catch memory leaks

ecs_fini(world);
}

void Stats_progress_stats_systems_w_empty_table_flag(void) {
ecs_world_t *world = ecs_mini();

ecs_set_default_query_flags(world, EcsQueryMatchEmptyTables);

ECS_IMPORT(world, FlecsStats);

for (int i = 0; i < 60 * 60; i ++) {
ecs_progress(world, 0.016);
}

test_assert(true); // used to catch memory leaks

Expand Down
7 changes: 6 additions & 1 deletion test/addons/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ void Stats_get_entity_count(void);
void Stats_get_pipeline_stats_w_task_system(void);
void Stats_get_not_alive_entity_count(void);
void Stats_progress_stats_systems(void);
void Stats_progress_stats_systems_w_empty_table_flag(void);

// Testsuite 'Run'
void Run_setup(void);
Expand Down Expand Up @@ -1711,6 +1712,10 @@ bake_test_case Stats_testcases[] = {
{
"progress_stats_systems",
Stats_progress_stats_systems
},
{
"progress_stats_systems_w_empty_table_flag",
Stats_progress_stats_systems_w_empty_table_flag
}
};

Expand Down Expand Up @@ -2607,7 +2612,7 @@ static bake_test_suite suites[] = {
"Stats",
NULL,
NULL,
12,
13,
Stats_testcases
},
{
Expand Down

0 comments on commit 4db1bc1

Please sign in to comment.