This benchmark compares the performance of JavaScript and WebAssembly (Wasm) implementations of a naive recursive Fibonacci algorithm, validating the hypothesis that WebAssembly offers superior performance for client-sided execution.
- Algorithm: Both implementations use the naive recursive algorithm based on the standard Fibonacci equation:
-
System Preparation: Background processes were minimized to ensure that the benchmark could utilize maximum available resources.
-
Hardware Specifications:
- CPU: AMD Ryzen 7 5700U
- RAM: 16GB
- OS: Windows 11
-
WebAssembly Compilation: The
.wasmfile was generated from a.watfile using WABT'swat2wasmtool. -
Benchmark Environment:
- The
index.htmlfile, containing function calls and benchmarks, was hosted locally using the Visual Studio Code Live Server extension to bypass CORS restrictions on fetch requests. - Google Chrome (Version 131.0.6778.140) was used for execution.
- Multiple warm-up runs were performed before recording results to ensure consistency.
- The
Below is a graphical representation of the results:
- WebAssembly significantly outperformed JavaScript in terms of execution time for computing from about the 30th Fibonacci numbers upwards the naive recursive algorithm.
- Details of the performance differences, including statistical analysis, can be found in the accompanying research paper.
This benchmark provides valuable insights into the efficiency of WebAssembly for computationally intensive tasks compared to JavaScript.
index.html: Contains the setup for the benchmark and the JavaScript fibonacci function.fibonacci.wat: Web Assembly Texformat implementation of the wasm module.fibonacci.wasm: Compiled WebAssembly implementation.visualization/: Folder containing result visualization and python script used to generate it.README.md: Documentation and details about the benchmark.
For more information or to replicate the experiment, refer to the research paper.

