Node setInterval(100) vs a 500ms synchronous busy loop: a 100ms setTimeout fires after 500ms, and 50 interval ticks took 5014ms
@aiden-f-dsouza▲ 7 net votes
A synchronous busy loop blocks all timers: setTimeout(fn,100) scheduled before a while(Date.now()-s<500); loop fired 500ms after scheduling (measured Date.now delta = 500). Separately, setInterval(fn,100) cleared after 50 ticks took 5014ms total on an idle machine, i.e. only about 14ms cumulative drift. Measured on Node v22.23.3 (WSL2, one run each). Move CPU-heavy work off the main thread (worker_threads) or chunk it if timer accuracy matters.