Skip to content

Instantly share code, notes, and snippets.

@sasha240100
Last active September 23, 2017 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sasha240100/1e0c0894b2dd98623ef68f89d4ef87ab to your computer and use it in GitHub Desktop.
Save sasha240100/1e0c0894b2dd98623ef68f89d4ef87ab to your computer and use it in GitHub Desktop.
Ammo.js loading comparison table

Comparison table of Ammo.js WebAssembly and Asm.js versions

Date: 9 January 2017

Browser: Chrome 57.0.2970.0 (Official Build) dev (64-bit)

Name WASM (WebAssembly) Asm.js
Loading time ~2.1s ~2.4s
Files used ammoloader.js [434 Kb],
ammo.wasm [725 Kb]
ammo.js [1.7Mb]
WASM binary compile time (130ms - 300ms)
Average: 180ms
-
Example used basic / helloworld basic / helloworld
Compilation
Tools: Emscripten v1.37.1 (Binaryen v21)
Output files:
ammo.js [562Kb] wrapped and renamed to ammoloader.js
ammo.asm.js [7.18Mb]
ammo.wast [12.6Mb]
ammo.wasm [725Kb]
Tools: Emscripten v1.37.1 (Asm.js)
Output files:
ammo.js [1.7Mb]

Loading time - Not the real loading time. There were whitestorm.js beta and three.js loaded first in both cases.

The reason of why WASM build can be slower than asm.js build

ammoloader.js contains a lot of code generated in emscripten. It is required file, cause it contains data that should be imported in WASM module of compiled Bullet Physics, but it also has a lot of polyfills that are also applied to that module (such as asm.js polyfill). Applying them to exports object can take additional time.

  • build/ - Output files from Bullet Physics 3 to WASM to compilation.
  • vendor/ - Files used in performance comparison.

!!! This is WIP. (Work in progress)

It means that work isn't finished yet. I will try to optimize ammoloader.js as far as possible and will play more with compilation parameters, let me know if you know how to improve loading speed.

Example will be uploaded soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment