12

I'm trying to get for example loadEventEnd time in console. You can do it by performance timing 2 API or performance timing API. I get the same results by doing this calculations:

performance.getEntriesByType("navigation")[0].loadEventEnd
// 483.915
chrome.loadTimes().finishLoadTime * 1000 - chrome.loadTimes().startLoadTime * 1000 
// 484
performance.timing.loadEventEnd - performance.timing.navigationStart
// 484

But in Timeline tab in devtools I get result 510 ms. Differences are shown in this picture:

enter image description here

This problem occurs on the others sites: in console I always get shorter times than in Timeline tab. Can someone explain this difference? Which one time is real?

Everettss
  • 15,475
  • 9
  • 72
  • 98
  • 1
    Unfortunately, for some reason my installation of Chrome 58.0.3029.96 (64-bit) doesn't have Timeline tab, so I can't provide any actual research. However, my hunch is that the difference between console and Timeline is coming from a brief delay needed to boot up JavaScript for the new tab. In your example, the difference is 30ms - have you looked whether anything happens in Timeline tab around the 30ms mark? – Dragomok May 03 '17 at 11:53
  • 1
    @Dragomok You are right. At 26 ms in timeline appears `navigationStart` event. So if you subtract from `loadEventEnd` `navigationStart` you will end up with 484 ms. Problem was that timeline was recorded before `navigationStart` which is different for `navigation-timing-api`. – Everettss May 03 '17 at 12:49
  • 1
    @Dragomok in version 58 timeline is now in Performance tab. – Everettss May 03 '17 at 13:07

1 Answers1

1

As @Dragomok in comment suggest:

navigation-timing-api starts record on navigationStart event. Performance tab timeline starts records "some time" before navigationStart event, that's why performance.getEntriesByType("navigation")[0].loadEventEnd gives smaller value than loadEventEnd in timeline.

If you calculate timeline loadEventEnd - navigationStart you will get the same value as in navigation-timing-api.

Here is proof in pictures: enter image description here


enter image description here

Everettss
  • 15,475
  • 9
  • 72
  • 98