Hanks10100 / wasm-examples

WebAssembly Examples
227 stars 58 forks source link

matrix例子中 为什么webAssembly用时比js更长呀 #7

Open tttousa opened 4 years ago

tttousa commented 4 years ago

如题

Hanks10100 commented 4 years ago

现在 js 引擎的优化已经很厉害了,尤其是对 for 循环。 wasm 在浏览器里复用的是一部分 js 引擎的实现,性能还不行,跑在独立的 runtime 里会好一些。

tttousa commented 4 years ago

哦哦明白啦!谢谢您~ 还想问一下,最近我想研究 用webAssembly提高浏览器执行canvas或者webGL等一些渲染任务的速度,不知道可行嘛?

---原始邮件--- 发件人: "Hanks"<notifications@github.com> 发送时间: 2019年11月13日(星期三) 晚上7:25 收件人: "Hanks10100/wasm-examples"<wasm-examples@noreply.github.com>; 抄送: "Author"<author@noreply.github.com>;"tttousa"<1121755070@qq.com>; 主题: Re: [Hanks10100/wasm-examples] matrix例子中 为什么webAssembly用时比js更长呀 (#7)

现在 js 引擎的优化已经很厉害了,尤其是对 for 循环。 wasm 在浏览器里复用的是一部分 js 引擎的实现,性能还不行,跑在独立的 runtime 里会好一些。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hanks10100 commented 4 years ago

可以自己实验一下。 wasm 不是很适合做渲染,做高性能运算还可以,主要是目前 js 和 wasm 之间的传值效率不够高,如果频繁互相调用的话,挺影响性能的。

另外 wasm 是跑在 CPU 里的,大部分和 js 一样用在主线程里,浏览器主线程已经够忙的了, WebGL 可以写 shader 跑在 GPU 里,用它做渲染性能更好一些。

tttousa commented 4 years ago

好嘞!再次感谢您的回复!

---原始邮件--- 发件人: "Hanks"<notifications@github.com> 发送时间: 2019年11月15日(星期五) 上午10:06 收件人: "Hanks10100/wasm-examples"<wasm-examples@noreply.github.com>; 抄送: "Author"<author@noreply.github.com>;"tttousa"<1121755070@qq.com>; 主题: Re: [Hanks10100/wasm-examples] matrix例子中 为什么webAssembly用时比js更长呀 (#7)

可以自己实验一下。 wasm 不是很适合做渲染,做高性能运算还可以,主要是目前 js 和 wasm 之间的传值效率不够高,如果频繁互相调用的话,挺影响性能的。

另外 wasm 是跑在 CPU 里的,大部分和 js 一样用在主线程里,浏览器主线程已经够忙的了, WebGL 可以写 shader 跑在 GPU 里,用它做渲染性能更好一些。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.