-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1.js
31 lines (25 loc) · 821 Bytes
/
1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const wabt = require('wabt')();
async function main() {
const src = '1.wat';
const wasm = wabt.parseWat(src, fs.readFileSync(src, 'utf8'));
const {buffer} = wasm.toBinary({});
const {instance} = await WebAssembly.instantiate(buffer);
const {exports: e} = instance;
console.log('f11_branching', {
25: e.f11_branching(25),
100: e.f11_branching(100)
});
// console.log('f12_branching_pure', {
// 25: e.f12_branching_pure(25),
// 100: e.f12_branching_pure(100)
// });
// console.log('f13_fibonacci_loop',
// Array.from({length: 10}, (_, i) => e.f13_fibonacci_loop(i)));
// console.log('f14_fibonacci_recursive',
// Array.from({length: 10}, (_, i) => e.f14_fibonacci_recursive(i)));
}
main().catch(e => {
console.error(e);
process.exit(1);
});