Created
June 27, 2018 07:42
-
-
Save gskachkov/185d9a21d77cab47903d5a6f83d441f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = '../out/main.wasm'; | |
let instance = null; | |
fetch(x).then(response => | |
response.arrayBuffer() | |
).then(bytes => | |
WebAssembly.instantiate(bytes, { | |
env: { | |
add_js: (a, b) => a + b | |
} | |
}) | |
).then(results => { | |
instance = results.instance; | |
const arr = []; | |
const start = performance.now(); | |
for (var i = 0; i < 1000000; i++) { | |
arr.push(instance.exports.fibonacci_wasm(45)); | |
} | |
document.getElementById("container").innerText = arr[ arr.length - 1 ] + ":" + ( performance.now() - start ); | |
}).catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment