Is setInterval CPU intensive?

前端 未结 6 984
长情又很酷
长情又很酷 2020-11-29 04:14

I read somewhere that setInterval is CPU intensive. I created a script that uses setInterval and monitored the CPU usage but didn\'t notice a change. I want to know if there

6条回答
  •  [愿得一人]
    2020-11-29 05:02

    Function time > interval time is bad, you can't know when cpu hiccups or is slow one and it stacks on top of ongoing functions until pc freezes. Use settimeout or even better, process.nextick using a callback inside a settimeout.

提交回复
热议问题