Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome - Difference between event time in devtools timeline and performance timing API

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?

like image 752
Everettss Avatar asked Apr 30 '17 19:04

Everettss


People also ask

What is navigation timing API?

The Navigation Timing API provides data that can be used to measure the performance of a web site. Unlike JavaScript-based libraries that have historically been used to collect similar information, the Navigation Timing API can be much more accurate and reliable.

How do I debug chrome performance?

Google Chrome DevTools Google Chrome's DevTools is one of the best ways to measure JavaScript performance and debug any bottlenecks. You can open DevTools by running Google Chrome and then pressing Command+Option+I (Mac) or Control+Shift+I (Windows & Linux), or even just right-click and select Inspect.


1 Answers

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

like image 81
Everettss Avatar answered Oct 22 '22 00:10

Everettss