Webassembly and Javascript speed comparison
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src/js
test
.gitignore
README.md
package.json
webpack.config.js
webpack.config.test.js

README.md

Webassembly and javascript performance comparison

Requirements

To compile

Run npm install.

To compile the C environment to Javascript run:

emcc src/js/modules/c/environment.c -o src/js/modules/c/environment.js

or for best performance:

emcc src/js/modules/c/environment.c -o src/js/modules/c/environment.js -s NO_EXIT_RUNTIME=1 -O3 -Oz --memory-init-file 0

then add export {Module as default} at the end of the file src/js/c/environment.js

then run webpack

To choose between C, Vanilla js and web workers

Modify the strategy constant passed to game function in app.js, you can choose between:

  • vanilla for simple Vanilla JS.
  • workers for the Vanilla JS strategy which uses web workers to split the calculation in multiple threads.
  • wasm for the strategy which uses C compiled functions to calculate the next state.