-
Notifications
You must be signed in to change notification settings - Fork 0
/
printers.js
49 lines (43 loc) · 1.09 KB
/
printers.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
49
const { plot } = require("asciiplot");
function sortByPackageName(a, b) {
// package-[id] -> id
const aId = parseInt(a.package.split("-")[1]);
const bId = parseInt(b.package.split("-")[1]);
return aId - bId;
}
/** Format the two tests as a markdown table */
function makeMarkdownTable(dataTest1, dataTest2) {
const titles = [
"Package",
"Time multiple dirs in NODE_PATH (ms)",
"Time single NODE_PATH (ms)",
];
const table = [];
dataTest1.sort(sortByPackageName).forEach((item, index) => {
table.push([
item.package,
item.requireDurationMs,
dataTest2[index].requireDurationMs,
]);
});
console.log("| " + titles.join("|") + " |");
console.log("| " + titles.map(() => "---").join("|") + " |");
table.forEach((row) => {
console.log("| " + row.join(" | ") + " |");
});
}
/** Plot the NODE_PATH speeds in an ascii barchart */
function plotSpeeds(dataTest1) {
console.log(
plot(
dataTest1.map((item) => item.requireDurationMs),
{
height: 20,
},
),
);
}
module.exports = {
makeMarkdownTable,
plotSpeeds,
};