AssemblyScript / examples

A collection of AssemblyScript examples.
https://assemblyscript.org
MIT License
283 stars 50 forks source link

Confused about performance #28

Open GitHobi opened 1 year ago

GitHobi commented 1 year ago

Hi there. I'm new to WebAssembly and AssemblyScript ... I was looking to speed up JavaScript code and started to play around with it.

So I had a question: I was playing with the Mandelbrot demo. What I did is, I ported the code from the ts file, directly to the js file ... so I can calculate the mandelbot set either by the code in the compiled webassembly - or directly within the javascript code. I expected the webassmbly calculation to be (significantly?) quicker.

But actually these are my results:

Using Chrome: JavaScript Code ~ 530ms ... WebAssembly ~ 1000ms Using Firefox: JavaScript Code ~ 580ms ... WebAssembly ~ 570ms ("limit" set to do 800 iterations. My PC is running windows, AMD Ryzen 9 3900X)

So it seems that in Chrome the WebAssembly version is half as fast as the normal JavaScript version ... in Firefox both version are at least equal in performance.

Is this expected? Or am I missing something?