I built a simple javascript vs. WebAssembly/SIMD benchmark as follows:
var sum = 0;
for (var c=0; c<N; c++)
{
var v3 = new Vector3();
sum += vs.dot(e);
}
var sum = 0;
for (var c=0; c<N; c++)
{
var v3 = new WASM_Vector3();
sum += vs.dot(e);
}
where WASM_Vector3 is implemented by c++ with SSE4.2 -msimd128 and compiled into wasm.
When N<3000, WASM outperforms Pure-JS. The larger the N is, Pure-JS begins to out-perform WASM. I know this is because of delay between JS/WASM interface. But is there a way to improve the above code to minimize the interface delay?