Skip to content

Commit b527241

Browse files
authored
chore(stats script): various updates (#489)
* chore(stats script): various updates * build-perf: Remove extra debug console.log
1 parent 0940982 commit b527241

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

.github/scripts/analyze-builds.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const execLogErr = async (command) => {
102102
const outputPath = resolve(METRICS_PATH, `${jsapiVersion}.csv`);
103103
const stream = createWriteStream(outputPath);
104104
stream.write(
105-
"Sample,Build size (MB),Build file count,Main bundle file,Main bundle size (MB),Main bundle gzipped size (MB),Main bundle brotli compressed size (MB),Load time (ms),Total runtime (ms),Loaded size (MB),Total JS requests,JS heap size (MB)\n"
105+
"Sample,Build size (MB),Build file count,Main bundle file,Main bundle size (MB),Main bundle gzipped size (MB),Main bundle brotli compressed size (MB),Load time (ms),Total runtime (ms),Loaded size (MB),Total JS requests,Total HTTP requests,JS heap size (MB)\n"
106106
);
107107

108108
for (const [itemCount, sample] of sampleDirectories.entries()) {
@@ -145,7 +145,7 @@ const execLogErr = async (command) => {
145145
const pageTotalMB = (perfResults.pageTotalBytes / 1024 ** 2).toFixed(2);
146146
const JSHeapUsedSizeMB = (perfResults.JSHeapUsedSizeBytes / 1024 ** 2).toFixed(2);
147147

148-
const output = `${sampleName} ${packageVersion},${buildSizeMB},${buildFileCount},${mainBundleName},${mainBundleSizeMB},${mainBundleSizeGzipMB},${mainBundleSizeBrotliMB},${perfResults.elapsedRuntimeMS},${perfResults.totalScriptTimeMS},${pageTotalMB},${perfResults.totalJSRequests},${JSHeapUsedSizeMB}\n`;
148+
const output = `${sampleName} ${packageVersion},${buildSizeMB},${buildFileCount},${mainBundleName},${mainBundleSizeMB},${mainBundleSizeGzipMB},${mainBundleSizeBrotliMB},${perfResults.elapsedRuntimeMS},${perfResults.totalScriptTimeMS},${pageTotalMB},${perfResults.totalJSRequests},${perfResults.totalHTTPRequests},${JSHeapUsedSizeMB}\n`;
149149

150150
console.log("Writing results to CSV:", output);
151151
stream.write(output);

.github/scripts/build-perf.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ const puppeteer = require("puppeteer");
33
const WebServer = require("./WebServer");
44

55
let go, webserver;
6+
let test = 0;
67
let pageTotalBytes = 0;
78
let totalJSRequests = 0;
9+
let totalHTTPRequests = 0;
810
let performanceMarkStart, performanceMarkEnd;
911
const PORT = 3000; // Used for both WebServer and TEST_URL
1012
const TEST_URL = "http://localhost:" + PORT;
@@ -14,6 +16,7 @@ const TEST_URL = "http://localhost:" + PORT;
1416
* @param {Object} response
1517
*/
1618
const addResponseSize = async (response) => {
19+
totalHTTPRequests++;
1720
const url = response.url();
1821
const str = url.substring(url.length - 3, url.length);
1922
if (str === ".js") {
@@ -103,14 +106,16 @@ const capturePageMetrics = async (page, sampleName) => {
103106
* Useful for comparing against the `elapsedRuntimeMS`. Should not be used as an indicator of
104107
* application performance, it's most useful for troubleshooting.
105108
* totalJSRequests - total number of JavaScript files requested by the app
109+
* totalRequests = the total number of HTTP requests
106110
*/
107111
return {
108112
sampleName,
109113
elapsedRuntimeMS,
110114
pageTotalBytes,
111115
JSHeapUsedSizeBytes,
112116
totalScriptTimeMS,
113-
totalJSRequests
117+
totalJSRequests,
118+
totalHTTPRequests
114119
};
115120
};
116121

@@ -137,7 +142,7 @@ const browserPerformanceTest = async (path, sampleName = "") => {
137142
totalJSRequests = 0;
138143
startWebServer(path, PORT);
139144

140-
const browser = await puppeteer.launch({ headless: true });
145+
const browser = await puppeteer.launch({ headless: "new", args: ["--use-angle=default"] });
141146
const page = await browser.newPage();
142147
errorLogging(page);
143148
await pageSetup(page);
@@ -171,7 +176,6 @@ const browserPerformanceTest = async (path, sampleName = "") => {
171176
// Close it because we may need to test multiple directories
172177
const shutdown = await webserver.stop();
173178
console.log("Shutting down webserver:", shutdown);
174-
175179
return pageMetrics;
176180
} else {
177181
console.log("\x1b[41m\x1b[30mERROR page did not load:", path);
@@ -181,4 +185,5 @@ const browserPerformanceTest = async (path, sampleName = "") => {
181185
}
182186
};
183187

184-
module.exports = browserPerformanceTest;
188+
// browserPerformanceTest("../../esm-samples/jsapi-angular-cli/dist/");
189+
module.exports = browserPerformanceTest;

.github/scripts/build-size.js

+2
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ if (require.main === module) {
356356
performanceInfo.totalScriptTimeMS,
357357
`\n --> total JS requests:`,
358358
performanceInfo.totalJSRequests,
359+
`\n --> total HTTP requests:`,
360+
performanceInfo.totalHTTPRequests,
359361
`\n --> app load size:`,
360362
formatBytes(performanceInfo.pageTotalBytes, decimals, binary),
361363
`\n --> jsheap size:`,

.github/scripts/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "analysis",
33
"description": "Run analysis against ESM samples",
4-
"version": "0.1.0",
4+
"version": "0.2.0",
55
"dependencies": {
6-
"puppeteer": "^20.3.0",
6+
"puppeteer": "^21.3.8",
77
"express": "^4.18.2"
88
}
99
}

0 commit comments

Comments
 (0)