Ah yes. The speedup-loop.
https://thedailywtf.com/articles/The-Speedup-LoopI think some compilers will just drop that in the optimization step.
Real pain in the ass when you’re in embedded and your carefully placed NOPs get stripped
I just measured it, and this takes 0.17 seconds. And it’s really reliable, I added another zero to that number and it was 1.7 seconds
Javascript enters chat:
await new Promise(r => setTimeout(r, 2000));
Which is somehow even worse.
On microcontrollers that might be a valid approach.
But then I gotta buy a space heater too…
deleted by creator
Nah, some MCUs have low power modes.
ESP32 has 5 of them, from disabling fancy features, throttling the clock, even delegating to an ultra low power coprocessor, or just going to sleep until a pin wakes it up again. It can go from 240mA to 150uA and still process things, or sleep for only 5uA.
Tell the CPU to wait for you?
Na, keep the CPU busy with useless crap till you need it.
Have you considered a career in middle management