-
Notifications
You must be signed in to change notification settings - Fork 1
/
bench.mjs
45 lines (35 loc) · 1.07 KB
/
bench.mjs
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
import {
createGetFolderSizeBinIpc,
getFolderSize,
getFolderSizeBin,
} from "./npm/index.mjs";
const { getFolderSizeWithIpc, close } = createGetFolderSizeBinIpc();
const base = "../";
const nodeStartTime = Date.now();
const nodeResult = await getFolderSize(base, true);
const nodeDuration = Date.now() - nodeStartTime;
const goBinStartTime = Date.now();
const goBinResult = await getFolderSizeBin(base, true);
const goBinDuration = Date.now() - goBinStartTime;
const goIpcStartTime = Date.now();
const goIpcResult = await getFolderSizeWithIpc(base, true);
const goIpcDuration = Date.now() - goIpcStartTime;
close();
console.log(
`node - duration: ${nodeDuration / 1000}s result: ${nodeResult}`,
);
console.log(
`goBin - duration: ${goBinDuration / 1000}s result: ${goBinResult}`,
);
console.log(
`goIpc - duration: ${goIpcDuration / 1000}s result: ${goIpcResult}`,
);
console.log("\n");
console.log(
"goBin vs node -",
(nodeDuration / goBinDuration).toFixed(2) + " ↑",
);
console.log(
"goIpc vs node -",
(nodeDuration / goIpcDuration).toFixed(2) + " ↑",
);