Luckily, the User Timing API exists just for this purpose!
You set "marks" as points in time to reference, then you can measure the difference between various "marks" with a "measure" to get a duration.
This API is available for 95% of users globally today.21:06 PM - 16 Dec 2019
The Navigation and Resource Timing APIs are similar and give you detailed data on the document and its assets.
To preview the data, load a page and in the console type, for example:
youtube.com/watch?v=BAeghS…21:06 PM - 16 Dec 2019