mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-23 08:25:48 +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 fs from "fs";
|
||||||
import { parseArgs } from "node:util";
|
import { parseArgs } from "node:util";
|
||||||
|
import ttest from "ttest";
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
const ttest = require("ttest");
|
|
||||||
|
|
||||||
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
|
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
|
||||||
|
|
||||||
@ -72,12 +67,6 @@ function flatten(stats) {
|
|||||||
return rows;
|
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) {
|
function mean(array) {
|
||||||
return array.reduce((a, b) => a + b, 0) / array.length;
|
return array.reduce((a, b) => a + b, 0) / array.length;
|
||||||
}
|
}
|
||||||
@ -158,7 +147,7 @@ function stat(baseline, current) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add horizontal line
|
// 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);
|
rows.splice(1, 0, hline);
|
||||||
|
|
||||||
// print output
|
// print output
|
||||||
@ -166,7 +155,8 @@ function stat(baseline, current) {
|
|||||||
const groupCount = options.groupBy.length;
|
const groupCount = options.groupBy.length;
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
for (let i = 0; i < row.length; i++) {
|
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(" | "));
|
console.log(row.join(" | "));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user