Created
October 10, 2019 23:18
-
-
Save kg/64b2402fbc132927b71886e8bdfbd36e to your computer and use it in GitHub Desktop.
This file contains 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
const instance = new WebAssembly.Instance(wasmModule, {}); | |
const { count } = instance.exports; | |
var limit = 50000; | |
var speed = 100; | |
var res = null; | |
for (i = 0; i < limit; i += speed) { | |
try { | |
res = count(i, 0); | |
} catch (exc) { | |
console.log("failed at limit ", i, " with ", exc); | |
break; | |
} | |
} | |
console.log("result ", res); |
This file contains 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
(module | |
(func $count (export "count") (param $depth i32) (param $counter i32) (result i32) (local $one i32) | |
i32.const 1 | |
local.set $one | |
local.get $depth | |
i32.const 0 | |
i32.eq | |
if (result i32) | |
local.get $counter | |
return | |
else | |
local.get $depth | |
local.get $one | |
i32.sub | |
local.get $counter | |
local.get $one | |
i32.add | |
call $count | |
end | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment