Benchmarks

To get an overview how the performance of WebAssembly compares to other implementations, some benchmarks were done. The used benchmark code is from the Computer Language Benchmarks Game.

Note that these are only micro-benchmarks. They test one very specific implementation of something, whereas a real program would use multiple or complete other things that aren't tested here.

The benchmark sources can be found here.

Environment

Every benchmark runs 5 times and the final benchmark results are calculated from the average result of each run. All benchmarks are using NodeJS to execute them. NodeJS itself always has a performance/memory overhead as it needs to spin up a new V8 engine every time, which is the explanation why the base memory is so high.

Host & OS:

  • Raspberry Pi 4, 2GB RAM
  • Raspberry Pi OS Lite, 64 bit, 2024-11-19

Software:

  • Rust v1.85.0
  • NodeJS v23.7.0
  • Emscripten v4.0.4

Benchmarked Software:

  • WebAssembly (wasm); mlua v0.10.3
  • Fengari (fengari); fengari v0.1.4

Results

binary-trees

xsourcesecsmem(kb)cpu secs
1.000wasm #20.394635230.250
1.944fengari #20.766764010.516
binary-trees with default arguments

fasta

xsourcesecsmem(kb)cpu secs
1.000wasm #30.418658400.290
1.000wasm #20.418660040.290
3.464fengari #21.448924100.830
3.474fengari #31.452885310.816
fasta with default arguments

mandelbrot

xsourcesecsmem(kb)cpu secs
1.000wasm #30.366597290.282
1.000wasm0.366597940.282
1.011wasm #20.370596560.290
3.208fengari1.174735710.910
3.410fengari #31.248731950.986
3.552fengari #21.300724891.016
mandelbrot with default arguments

n-body

xsourcesecsmem(kb)cpu secs
1.000wasm0.380617050.270
1.011wasm #40.384625630.284
1.016wasm #20.386625520.276
2.832fengari #21.076746350.626
2.842fengari1.080754420.650
2.863fengari #41.088746270.626
n-body with default arguments

spectral-norm

xsourcesecsmem(kb)cpu secs
1.000wasm0.554595670.450
4.801fengari2.660756512.324
spectral-norm with default arguments