forked from jupyterlab/jupyterlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jupyterlab#5870 from saulshanabrook/lighthouse
Profile with lighthouse
- Loading branch information
Showing
7 changed files
with
782 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
}, | ||
"devDependencies": { | ||
"@types/node-fetch": "^2.3.4", | ||
"lighthouse": "5.1.0", | ||
"typescript": "~3.5.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Compares two files lighthouse outputs, listing changes between the numeric audits. | ||
* | ||
* Outputs in Markdown for easy posting in Github. | ||
*/ | ||
import { readFileSync } from 'fs'; | ||
|
||
const firstFilePath = process.argv[2]; | ||
const secondFilePath = process.argv[3]; | ||
|
||
console.log(`\`${firstFilePath}\` -> \`${secondFilePath}\`\n\n`); | ||
interface IOutput { | ||
audits: { | ||
[name: string]: { | ||
id: string; | ||
title: string; | ||
description: string; | ||
scoreDisplayMode: string; | ||
displayValue: string; | ||
numericValue: number; | ||
}; | ||
}; | ||
} | ||
|
||
const first: IOutput = JSON.parse(readFileSync(firstFilePath).toString()); | ||
const second: IOutput = JSON.parse(readFileSync(secondFilePath).toString()); | ||
|
||
for (const auditName in first.audits) { | ||
const firstAudit = first.audits[auditName]; | ||
|
||
// only compare numeric audits | ||
if (firstAudit.scoreDisplayMode !== 'numeric') { | ||
continue; | ||
} | ||
const secondAudit = second.audits[auditName]; | ||
const percentChange = | ||
((secondAudit.numericValue - firstAudit.numericValue) / | ||
firstAudit.numericValue) * | ||
100; | ||
|
||
if (isNaN(percentChange)) { | ||
continue; | ||
} | ||
console.log( | ||
`**${firstAudit.title}**\n* ${percentChange.toFixed(0)}% Δ\n* ${ | ||
firstAudit.displayValue | ||
} -> ${secondAudit.displayValue}\n* ${firstAudit.description}\n` | ||
); | ||
} |
Oops, something went wrong.