How to get the time to load the iframe using onload

I have a lisst of urls that I have to use as a source for the iframe. So after creating child and appending to the DOM, I run the onload function to do further processing but the time that I get for each iframe is not correct. The code is as follows –

`var s = document.createElement('iframe');
document.body.appendChild(s);
s.onload = function() {
var totalTime = performance.now() - startTime;
console.log(document.body);
console.log(totalTime, element);
timestamps.push(totalTime);
}
s.src=url;
var startTime = performance.now();
}`

So here URL is one of the urls from that array and I have to get the time to check how much time a iframe (url) takes to load.

To test the time, in of the url endpoint I put a sleep function so that I can validate that the time to load that is more than any other case. But it never happens that I get the max time on that endpoint.