How fast are Web Worker's messages?

后端 未结 2 393
鱼传尺愫
鱼传尺愫 2020-12-16 00:36

I wondered if transmission to or from a web worker can be a bottleneck. Should we post message just as we trigger any kind of events, or should we take care and try to limit

2条回答
  •  情话喂你
    2020-12-16 01:07

    They are as fast as the cpu core that's running it. Having that said, communication between processes always incurs some overhead so batching it will probably net you some additional performance. Personally I would probably use a timer to send the mouse location or location history every 25ms.

    The question you should ask yourself is: how often do you need the updates? Is 1 update per second enough? 100? 1000? At what point are you just burning cpu cycles for no added value.

提交回复
热议问题