@@ -197,7 +197,7 @@ function getComputedRenderBeaconSpans<
197
197
string ,
198
198
{
199
199
firstStart : number
200
- lastEnd : number | undefined
200
+ firstContentfulRenderEnd : number | undefined
201
201
firstLoadingEnd : number | undefined
202
202
firstContentStart : number | undefined
203
203
renderCount : number
@@ -227,15 +227,19 @@ function getComputedRenderBeaconSpans<
227
227
)
228
228
if ( ! scopeMatch ) continue
229
229
const start = startTime . now
230
- const contentEnd =
231
- renderedOutput === 'content' ? start + duration : undefined
230
+ const contentfulRenderEnd =
231
+ entry . span . type === 'component-render' && renderedOutput === 'content'
232
+ ? start + duration
233
+ : undefined
232
234
233
235
const spanTimes = renderSpansByBeacon . get ( name )
234
236
237
+ // TODO: make sure that sumOfRenderDurations takes into account that mismatch between render-start and full render - might be discarded and re-render - should extend the first render duration from the first render start to the first end
238
+
235
239
if ( ! spanTimes ) {
236
240
renderSpansByBeacon . set ( name , {
237
241
firstStart : start ,
238
- lastEnd : contentEnd ,
242
+ firstContentfulRenderEnd : contentfulRenderEnd ,
239
243
renderCount : entry . span . type === 'component-render' ? 1 : 0 ,
240
244
sumOfDurations : duration ,
241
245
firstContentStart : renderedOutput === 'content' ? start : undefined ,
@@ -246,10 +250,10 @@ function getComputedRenderBeaconSpans<
246
250
} )
247
251
} else {
248
252
spanTimes . firstStart = Math . min ( spanTimes . firstStart , start )
249
- spanTimes . lastEnd =
250
- contentEnd && spanTimes . lastEnd
251
- ? Math . max ( spanTimes . lastEnd , contentEnd )
252
- : contentEnd ?? spanTimes . lastEnd
253
+ spanTimes . firstContentfulRenderEnd =
254
+ contentfulRenderEnd && spanTimes . firstContentfulRenderEnd
255
+ ? Math . min ( spanTimes . firstContentfulRenderEnd , contentfulRenderEnd )
256
+ : contentfulRenderEnd ?? spanTimes . firstContentfulRenderEnd
253
257
if ( entry . span . type === 'component-render' ) {
254
258
spanTimes . renderCount += 1
255
259
}
@@ -277,18 +281,19 @@ function getComputedRenderBeaconSpans<
277
281
278
282
// Calculate duration and startOffset for each beacon
279
283
for ( const [ beaconName , spanTimes ] of renderSpansByBeacon ) {
280
- if ( ! spanTimes . lastEnd ) continue
284
+ if ( ! spanTimes . firstContentfulRenderEnd ) continue
281
285
computedRenderBeaconSpans [ beaconName ] = {
282
286
startOffset : spanTimes . firstStart - input . startTime . now ,
283
- timeToContent : spanTimes . lastEnd - spanTimes . firstStart ,
284
- timeToLoading : spanTimes . firstLoadingEnd
287
+ firstRenderTillContent :
288
+ spanTimes . firstContentfulRenderEnd - spanTimes . firstStart ,
289
+ firstRenderTillLoading : spanTimes . firstLoadingEnd
285
290
? spanTimes . firstLoadingEnd - spanTimes . firstStart
286
291
: 0 ,
287
- timeToData : spanTimes . firstContentStart
292
+ firstRenderTillData : spanTimes . firstContentStart
288
293
? spanTimes . firstContentStart - spanTimes . firstStart
289
294
: 0 ,
290
295
renderCount : spanTimes . renderCount ,
291
- sumOfDurations : spanTimes . sumOfDurations ,
296
+ sumOfRenderDurations : spanTimes . sumOfDurations ,
292
297
}
293
298
}
294
299
0 commit comments