Is multithreading with webworkers ineffective?

拥有回忆 提交于 2019-12-01 10:30:29

Your benchmark is being swamped by the cost of transferring ten million numbers to each worker.

Instead, create a ArrayBuffer. Pass that, as part of transferList (the second parameter to postMessage). On my machine the workers run this job in less than 100ms compared to 200ms without the workers.

See https://jsfiddle.net/ooduhb5h/7/.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!