[ci] yarn format

This commit is contained in:
natemoo-re 2022-02-18 20:24:55 +00:00 committed by GitHub Actions
parent 23783648b6
commit 3c2eee5732
2 changed files with 25 additions and 19 deletions

View file

@ -9,7 +9,8 @@ import prettyBytes from 'pretty-bytes';
const projDir = new URL('./project/', import.meta.url);
function mean(numbers) {
var total = 0, i;
var total = 0,
i;
for (i = 0; i < numbers.length; i += 1) {
total += numbers[i];
}
@ -18,15 +19,18 @@ function mean(numbers) {
function median(numbers) {
// median of [3, 5, 4, 4, 1, 1, 2, 3] = 3
var median = 0, numsLen = numbers.length;
var median = 0,
numsLen = numbers.length;
numbers.sort();
if (
numsLen % 2 === 0 // is even
numsLen % 2 ===
0 // is even
) {
// average of two middle numbers
median = (numbers[numsLen / 2 - 1] + numbers[numsLen / 2]) / 2;
} else { // is odd
} else {
// is odd
// middle number only
median = numbers[(numsLen - 1) / 2];
}
@ -35,7 +39,7 @@ function median(numbers) {
}
let config = await loadConfig({
cwd: fileURLToPath(projDir)
cwd: fileURLToPath(projDir),
});
config.buildOptions.experimentalStaticBuild = true;
@ -71,11 +75,13 @@ let medianOfAll = median(sizes);
// If the trailing average is higher than the median, see if it's more than 5% higher
if (averageOfLastThirty > medianOfAll) {
let percentage = Math.abs(averageOfLastThirty - medianOfAll) / medianOfAll;
if(percentage > .05) {
throw new Error(`The average towards the end (${prettyBytes(averageOfLastThirty)}) is more than 5% higher than the median of all runs (${prettyBytes(medianOfAll)}). This tells us that memory continues to grow and a leak is likely.`)
if (percentage > 0.05) {
throw new Error(
`The average towards the end (${prettyBytes(averageOfLastThirty)}) is more than 5% higher than the median of all runs (${prettyBytes(
medianOfAll
)}). This tells us that memory continues to grow and a leak is likely.`
);
}
}
await server.stop();