3 ms·
A while back I personally tested performance of C (-O3 compiled to WASM and x64) vs JS for basic math and string operations. Overall results: Almost no differe
by DanielHB 3y ago
A while back I personally tested performance of C (-O3 compiled to WASM and x64) vs JS for basic math and string operations. Overall results:
Almost no difference for string manipulation
little difference for floating-point math
big perf difference for integer math
WASM vs JS also saw little differences in performance (except for integer math), in some cases it was slightly slower
There are several reasons to use a lower level language, but raw speed is hardly ever of note. It usually comes down to how good the libs you are using are. As Bun is showing even the stdlib of your runtime can be lackluster
- jrajav 3y agoJust curious, how did you run integer math in JS to compare? Since it doesn't support it natively.
- DanielHB 3y agoI wrote a few test cases in both JS and C doing some computations inside a loop. The code between the versions was equivalent and not micro-optimized. In JS was using normal variables so they were stored in memory as IEEE754 (unless the engine was doing some optimisations I was not aware of). So no manual binary math with buffers in JS I was specifically looking how big of an impact it is to use normal JS numbers for integer-heavy math. It turns out it is quite big, but for float64 math, not so much.