Hi to all Emscripters!
;-)
I am looking for some performance tests comparing manually optimized JavaScript code vs. emscripted C++ vs. native C++.
Some people in my company are dismissing Emscripten as too slow and I want to identified areas where it indeed is and where it is as fast as native.
Some time ago, I found somebody's simple C++ code generating Pi to any number of digits. This code doesn't have a lot of data, but does a lot of number crunching on some limited data. To my surprise, emscripted code showed the same performance, within the error of measurement, as the native code (built on different platforms with different compilers).
Then, while working on a multi-platform CAD application, which is built for both desktop platforms and Web, I've observed emscripted code being 3...5 times slower than the native code, when operating on models taking up to 1 GB of memory. I used Chrome profiler and was pleased to see that copying JS Typed Arrays to Emscripten heap was relatively fast--this code took less than a second to copy(?) hundreds of megabytes of Uint8Array:
var length = javascriptArray.length;
var geometry = Module._malloc(length);
var emscrHeap = new Uint8Array(Module.HEAPU8.buffer, geometry, length);
emscrHeap.set(new Uint8Array(javascriptArray.buffer));
But the, originally C++ and then emscripted, code performing geometry manipulations on these large models is several times slower than native.
Where is the source of this slowness, accessing JS TypedArrays is so much slower than operating with C pointers and C++ STL containers?
Thank you,
Boris