-
-
Save dherman/30f60f46f182f247b2aac7d71c33dee7 to your computer and use it in GitHub Desktop.
asm.js sample
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
function fast_fib_module(stdlib, foreign, heap) { | |
"use asm"; | |
function fib(n) { | |
n = n|0; | |
if (n >>> 0 < 3) { | |
return 1|0; | |
} | |
return (fib((n-1)|0) + fib((n-2)|0))|0; | |
} | |
return fib; | |
} | |
fast_fib = fast_fib_module(window); | |
function slow_fib(n) { | |
if (n < 3) { | |
return 1; | |
} | |
return slow_fib(n-1) + slow_fib(n-2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment