Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in flecs::stats module when global MatchEmptyTables flag is set #1373

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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