-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainc_bench.ts
57 lines (48 loc) · 1.06 KB
/
mainc_bench.ts
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
49
50
51
52
53
54
55
56
57
export function benchQuickTest() {
const a = 1;
const b = 2;
const c = a + b;
}
export function benchSlowTest() {
let a = 0;
for (var i = 0; i < 1000000; i++) {
a += 1;
}
}
export function benchReallySlowTest() {
let a = 0;
for (var i = 0; i < 100000000; i++) {
a += 1;
}
}
export function compareNonAsyncTests() {
return [ benchQuickTest, benchSlowTest, benchReallySlowTest ];
}
export async function benchAsyncQuickTest() {
const a = 1;
const b = 2;
const c = a + b;
}
export async function benchAsyncSlowTest() {
return new Promise((resolve) => {
setTimeout(() => {
const a = 1;
resolve(null);
}, 300);
});
}
export async function benchAsyncReallySlowTest() {
return new Promise((resolve) => {
setTimeout(() => {
const a = 1;
resolve(null);
}, 3000);
});
}
export function compareAsyncTests() {
return [
benchAsyncQuickTest,
benchAsyncSlowTest,
benchAsyncReallySlowTest,
];
}