webassembly icon indicating copy to clipboard operation
webassembly copied to clipboard

Mini benchmark example

Open mini-eggs opened this issue 8 years ago • 2 comments

Comparing how long it takes to add two numbers in JavaScript vs WebAssembly. Complete with simple Webpack config, NPM scripts, and Readme details.

Lemme know what ya'll thinking 😃

mini-eggs avatar Jun 06 '17 22:06 mini-eggs

Overlooked some things here, I'll be making another commit. Also, WebAssembly is only faster in an async func with try/catch :)

mini-eggs avatar Jun 06 '17 23:06 mini-eggs

Yeah, WebAssembly should actually be slower in this exact scenario because of the additional indirection layer (calling into a WebAssembly module and pulling something out while converting the input and output value from/to a JS number, which is a wrapped double basically), while the comparison function in plain JS will simply be JITed to efficient machine code.

dcodeIO avatar Jun 06 '17 23:06 dcodeIO