3 ms·
The first benchmark isn't measuring the performance of WASM, but the calling overhead from JS to WASM (which is pretty small, but it's still an optimization bar
by flohofwoe 4y ago
The first benchmark isn't measuring the performance of WASM, but the calling overhead from JS to WASM (which is pretty small, but it's still an optimization barrier for the JS engine).
The second benchmark isn't measuring the performance of Javascript, but the performance of the Javascript sort() call (which most likely is implemented as native code).
In general, WASM should be both in the same ballpark as portable natively compiled code (e.g. not using SIMD), as well as Javascript which has been written for performance (which also means that well written - but non-idiomatic - Javascript can be in the same ballpark as portable native code).
The main advantage of WASM versus JS isn't mainly performance, but predictable performance (because the GC is taken out of the picture, and the linear memory model), and that WASM is a better compilation target than JS.