@@ -78,6 +78,11 @@ interface Problem {
7878 detail : string
7979}
8080
81+ interface PageRead {
82+ path : string
83+ ms : number
84+ }
85+
8186interface FirstPaint {
8287 persona : string
8388 page : string
@@ -109,6 +114,11 @@ export const routes: {
109114 platformSurfaces : number
110115 /** From the document's load to no read or skeleton left, or null if it never got there. */
111116 contentReadyMs : number | null
117+ /** The document's own load, which `contentReadyMs` starts after. */
118+ documentMs : number
119+ /** Where the route's time went: its slowest reads, and how many it sent. */
120+ slowestReads : PageRead [ ]
121+ readCount : number
112122} [ ] = [ ]
113123export const firstPaints : FirstPaint [ ] = [ ]
114124const unexpected : Problem [ ] = [ ]
@@ -260,6 +270,9 @@ class Session {
260270 /** The document a navigation is loading, until it replaces the page. */
261271 private loadingDocument : Request | null = null
262272 readonly requests : { method : string ; path : string ; type : string } [ ] = [ ]
273+ /** The page's own reads and how long each took, from the last navigation a walk started. */
274+ readonly reads : PageRead [ ] = [ ]
275+ private readonly readStarted = new Map < Request , number > ( )
263276
264277 constructor (
265278 readonly context : BrowserContext ,
@@ -287,6 +300,7 @@ class Session {
287300 if ( isPageRead ( request ) ) {
288301 this . inflight . add ( request )
289302 this . lastActivity = Date . now ( )
303+ this . readStarted . set ( request , Date . now ( ) )
290304 }
291305 if ( isSameOrigin ( request . url ( ) ) )
292306 this . requests . push ( {
@@ -305,6 +319,13 @@ class Session {
305319 } )
306320 const settled = ( request : Request ) => {
307321 if ( this . inflight . delete ( request ) ) this . lastActivity = Date . now ( )
322+ const started = this . readStarted . get ( request )
323+ if ( started === undefined ) return
324+ this . readStarted . delete ( request )
325+ this . reads . push ( {
326+ path : `${ request . method ( ) } ${ pathOf ( request . url ( ) ) } ` ,
327+ ms : Date . now ( ) - started ,
328+ } )
308329 }
309330 page . on ( 'requestfinished' , settled )
310331 page . on ( 'requestfailed' , ( request ) => {
0 commit comments