obs-advanced-timer icon indicating copy to clipboard operation
obs-advanced-timer copied to clipboard

High CPU usage because of `script_tick()`

Open scy opened this issue 3 years ago • 1 comments

This script causes my OBS CPU usage to go up from 2.5 % to 6 %. After looking at the source, I can see that this is because you’re using script_tick() to update the timer once per rendered frame (e.g. 60 times per second if using 60 fps). However, my timer only uses minutes and seconds. 59 out of 60 updates per second are not needed because the text doesn’t change.

My suggestion would be to use timer_add() instead and be called by OBS only as often as required.

I know that it’s possible to use sub-second precision in a timer by changing the format string. Therefore, setting a 1000 ms timer is not always sufficient. Instead, the timer interval should either be manually configurable, or derived automatically depending on the format string placeholders used.

scy avatar May 13 '21 18:05 scy

Tried to do this with 250ms interval in 4ad0a62b5866693a754ca2f837688dbe7cf06aad and it works. However, I didn't notice CPU load change.

RomanTruba avatar Mar 27 '23 16:03 RomanTruba