-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (40 loc) · 1.42 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Benchmark from "benchmark";
import { fibonacciAs, fibRecurseAs } from "../build/as-fib.release.js";
import { fibonacciJs, fibRecurseJs } from "../assembly/index.js";
function runSuite(suite) {
console.info("Running", suite.name);
suite
.on("cycle", function (event) {
console.info("\t" + event.target.toString());
})
.on("complete", function (_event) {
console.info(this.filter("fastest").map("name") + " won.\n");
})
.run();
}
function fibonacciSuites() {
const fibonacci_3 = Benchmark.Suite("fibonacci_3");
fibonacci_3
.add("AssemblyScript", () => fibonacciAs(3))
.add("JavaScript", () => fibonacciJs(3));
runSuite(fibonacci_3);
const fibonacci_25 = Benchmark.Suite("fibonacci_25");
fibonacci_25
.add("AssemblyScript", () => fibonacciAs(25))
.add("JavaScript", () => fibonacciJs(25));
runSuite(fibonacci_25);
}
function fibRecurseSuites() {
const fibRecurse_3 = Benchmark.Suite("fibRecurse_3");
fibRecurse_3
.add("AssemblyScript", () => fibRecurseAs(3))
.add("JavaScript", () => fibRecurseJs(3));
runSuite(fibRecurse_3);
const fibRecurse_25 = Benchmark.Suite("fibRecurse_25");
fibRecurse_25
.add("AssemblyScript", () => fibRecurseAs(25))
.add("JavaScript", () => fibRecurseJs(25));
runSuite(fibRecurse_25);
}
fibonacciSuites();
fibRecurseSuites();