@@ -3,8 +3,10 @@ const puppeteer = require("puppeteer");
3
3
const WebServer = require ( "./WebServer" ) ;
4
4
5
5
let go , webserver ;
6
+ let test = 0 ;
6
7
let pageTotalBytes = 0 ;
7
8
let totalJSRequests = 0 ;
9
+ let totalHTTPRequests = 0 ;
8
10
let performanceMarkStart , performanceMarkEnd ;
9
11
const PORT = 3000 ; // Used for both WebServer and TEST_URL
10
12
const TEST_URL = "http://localhost:" + PORT ;
@@ -14,6 +16,7 @@ const TEST_URL = "http://localhost:" + PORT;
14
16
* @param {Object } response
15
17
*/
16
18
const addResponseSize = async ( response ) => {
19
+ totalHTTPRequests ++ ;
17
20
const url = response . url ( ) ;
18
21
const str = url . substring ( url . length - 3 , url . length ) ;
19
22
if ( str === ".js" ) {
@@ -103,14 +106,16 @@ const capturePageMetrics = async (page, sampleName) => {
103
106
* Useful for comparing against the `elapsedRuntimeMS`. Should not be used as an indicator of
104
107
* application performance, it's most useful for troubleshooting.
105
108
* totalJSRequests - total number of JavaScript files requested by the app
109
+ * totalRequests = the total number of HTTP requests
106
110
*/
107
111
return {
108
112
sampleName,
109
113
elapsedRuntimeMS,
110
114
pageTotalBytes,
111
115
JSHeapUsedSizeBytes,
112
116
totalScriptTimeMS,
113
- totalJSRequests
117
+ totalJSRequests,
118
+ totalHTTPRequests
114
119
} ;
115
120
} ;
116
121
@@ -137,7 +142,7 @@ const browserPerformanceTest = async (path, sampleName = "") => {
137
142
totalJSRequests = 0 ;
138
143
startWebServer ( path , PORT ) ;
139
144
140
- const browser = await puppeteer . launch ( { headless : true } ) ;
145
+ const browser = await puppeteer . launch ( { headless : "new" , args : [ "--use-angle=default" ] } ) ;
141
146
const page = await browser . newPage ( ) ;
142
147
errorLogging ( page ) ;
143
148
await pageSetup ( page ) ;
@@ -171,7 +176,6 @@ const browserPerformanceTest = async (path, sampleName = "") => {
171
176
// Close it because we may need to test multiple directories
172
177
const shutdown = await webserver . stop ( ) ;
173
178
console . log ( "Shutting down webserver:" , shutdown ) ;
174
-
175
179
return pageMetrics ;
176
180
} else {
177
181
console . log ( "\x1b[41m\x1b[30mERROR page did not load:" , path ) ;
@@ -181,4 +185,5 @@ const browserPerformanceTest = async (path, sampleName = "") => {
181
185
}
182
186
} ;
183
187
184
- module . exports = browserPerformanceTest ;
188
+ // browserPerformanceTest("../../esm-samples/jsapi-angular-cli/dist/");
189
+ module . exports = browserPerformanceTest ;
0 commit comments