9 Replies
I doubt it, you can benchmark though
FFI should be faster afaik
but it depends on whatever you are FFI-ing to
IIRC, Sqlite is a lot faster in FFI than in WASM
in short FFI will always be faster than WASM because of how it works (being sandboxed and all that)
I kinda but not really benchmarked it once by using rust for image generation
wasm was about 2x slower but it's likely caused by the amount of allocating needed
it was still decently fast though
& wasm_bindgen is more polished than deno_bindgen
i couldn't get the latter to work so I had to use raw ffi
What about FFI vs JS for something trivial like adding two numbers?
I presume there is an startup overhead for FFI which will make it slower
Crossing brain-blood barrier can be costly for small tasks.
Generally WASM is slower than FFI. This does not always matter though. Sometimes you need to use a system API that Deno does not expose bindings for, in which case you must use FFI. However, FFI does not work on Deno Deploy, so WASM may be better suited if you have stronger security restrictions (such as in Deno Deploy).
yea and there is no difference in performance between native code and JS for such operations
FFI will also be slower since it will need to call a function from the lib