|
1 | | -/* eslint-disable import/no-commonjs */ |
2 | | - |
3 | | -import { createRequire } from "module"; |
4 | 1 | import fs from "fs"; |
5 | 2 | import { parseArgs } from "node:util"; |
6 | | - |
7 | | -const require = createRequire(import.meta.url); |
8 | | -const ttest = require("ttest"); |
| 3 | +import ttest from "ttest"; |
9 | 4 |
|
10 | 5 | const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"]; |
11 | 6 |
|
@@ -72,12 +67,6 @@ function flatten(stats) { |
72 | 67 | return rows; |
73 | 68 | } |
74 | 69 |
|
75 | | -function pad(s, length, dir /* default: 'right' */) { |
76 | | - s = "" + s; |
77 | | - const spaces = new Array(Math.max(0, length - s.length + 1)).join(" "); |
78 | | - return dir === "left" ? spaces + s : s + spaces; |
79 | | -} |
80 | | - |
81 | 70 | function mean(array) { |
82 | 71 | return array.reduce((a, b) => a + b, 0) / array.length; |
83 | 72 | } |
@@ -158,15 +147,16 @@ function stat(baseline, current) { |
158 | 147 | } |
159 | 148 |
|
160 | 149 | // add horizontal line |
161 | | - const hline = width.map(w => new Array(w + 1).join("-")); |
| 150 | + const hline = width.map(w => "-".repeat(w)); |
162 | 151 | rows.splice(1, 0, hline); |
163 | 152 |
|
164 | 153 | // print output |
165 | 154 | console.log("-- Grouped By " + options.groupBy.join(", ") + " --"); |
166 | 155 | const groupCount = options.groupBy.length; |
167 | 156 | for (const row of rows) { |
168 | 157 | for (let i = 0; i < row.length; i++) { |
169 | | - row[i] = pad(row[i], width[i], i < groupCount ? "right" : "left"); |
| 158 | + row[i] = |
| 159 | + i < groupCount ? row[i].padEnd(width[i]) : row[i].padStart(width[i]); |
170 | 160 | } |
171 | 161 | console.log(row.join(" | ")); |
172 | 162 | } |
|
0 commit comments