mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-10 07:14:04 +02:00
Merge pull request #20998 from Snuffleupagus/statcmp-import
Use a standard import for the `ttest` package in `test/stats/statcmp.js`
This commit is contained in:
commit
8941695fe8
@ -1,11 +1,6 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
import { createRequire } from "module";
|
||||
import fs from "fs";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const ttest = require("ttest");
|
||||
import ttest from "ttest";
|
||||
|
||||
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
|
||||
|
||||
@ -72,12 +67,6 @@ function flatten(stats) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
function pad(s, length, dir /* default: 'right' */) {
|
||||
s = "" + s;
|
||||
const spaces = new Array(Math.max(0, length - s.length + 1)).join(" ");
|
||||
return dir === "left" ? spaces + s : s + spaces;
|
||||
}
|
||||
|
||||
function mean(array) {
|
||||
return array.reduce((a, b) => a + b, 0) / array.length;
|
||||
}
|
||||
@ -158,7 +147,7 @@ function stat(baseline, current) {
|
||||
}
|
||||
|
||||
// add horizontal line
|
||||
const hline = width.map(w => new Array(w + 1).join("-"));
|
||||
const hline = width.map(w => "-".repeat(w));
|
||||
rows.splice(1, 0, hline);
|
||||
|
||||
// print output
|
||||
@ -166,7 +155,8 @@ function stat(baseline, current) {
|
||||
const groupCount = options.groupBy.length;
|
||||
for (const row of rows) {
|
||||
for (let i = 0; i < row.length; i++) {
|
||||
row[i] = pad(row[i], width[i], i < groupCount ? "right" : "left");
|
||||
row[i] =
|
||||
i < groupCount ? row[i].padEnd(width[i]) : row[i].padStart(width[i]);
|
||||
}
|
||||
console.log(row.join(" | "));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user