fix(benchmark): prevent infinite loop in is_optimization_enabled on tickless simulators (#10348)

Signed-off-by: Vandra-Meyer Akos <akos@lvgl.io>
This commit is contained in:
Akos Vandra-Meyer
2026-07-20 07:22:50 +02:00
committed by GitHub
parent a73e59f6d1
commit 1df2741e70
+10
View File
@@ -1005,6 +1005,16 @@ static bool is_optimization_enabled(void)
loop_not_optimizable();
}
t_unoptimized = lv_tick_elaps(t);
/*On some simulators (e.g. Zephyr's native_sim "inf_clock" model) the
*system tick only advances while the CPU is idle, so a busy loop like
*this never sees time elapse. In that case `t_unoptimized` stays 0 no
*matter how much work is done and the loop would never terminate.
*Detect it (a large amount of work with zero elapsed time) and give up
*measuring rather than hanging; assume optimizations are enabled.*/
if(t_unoptimized == 0 && max_cnt >= 1024) {
return true;
}
} while(t_unoptimized < 50);
/*Run the optimizable loop the same amount of times*/