clay
clay copied to clipboard
[Renderers/Raylib] CPU load is high
try build raylib-sidebar-scrolling-container, raylib-multi-context, and SDL3-simple-demo on macOS, the CPU load is around 10% to 70%.
raylib-sidebar-scrolling-container logs:
layout time: 70.566000 microseconds
layout time: 71.361000 microseconds
layout time: 71.475000 microseconds
layout time: 53.544000 microseconds
layout time: 69.166000 microseconds
layout time: 69.181000 microseconds
layout time: 68.377000 microseconds
layout time: 70.511000 microseconds
layout time: 100.101000 microseconds
layout time: 73.889000 microseconds
layout time: 98.027000 microseconds
layout time: 108.022000 microseconds
compare to Microsoft Edge or chrome, to load https://github.com/nicbarker/clay cpu load max around 40%. (browser on background cpu load is about 4%)
I just build them by:
cd clay/examples/SDL2-video-demo
cmake -DCMAKE_BUILD_TYPE=Release .
cmake --build . --config Release
Is this expected or I do something wrong?
For me, raylib is rendering as fast as it possibly can. Perhaps try limiting the fps.
add a SetTargetFPS(60); or similar helps alot
with SetTargetFPS(60), raylib-sidebar-scrolling-container cpu load around 25%, some time 50% if there is some action.
compare the browser cpu load without action, still much higher.
@calvin2021y Browsers by default won't re render if there is no user input - try watching the CPU usage when you're wiggling your mouse cursor over a page 🙂
Raylib has an equivalent setting you can enable that emulates this behaviour, with EnableEventWaiting();.
You can see that it's commented out in the example raylib renderer here: https://github.com/nicbarker/clay/blob/main/renderers/raylib/clay_renderer_raylib.c#L122
#298 May help a little.
thanks a lot for the tips.
after apply #298 and enable EnableEventWaiting(), build with lto. the cpu load is 5% ~ 20%. in background less than 1%.