0

I am trying to find out how much time it takes for url to load. For this I use file_get_contents:

$time_start = microtime(true); 
$homepage = file_get_contents('http://www.stackoverflow.com/');
$time_end = microtime(true); 
$execution_time = ($time_end - $time_start);

I think this way is incorrect because it wont load any of the javascript sources. I was thinking if I could somehow scan urls source code for javascript sources, then open each javascript source and get the time it took to load, then combine each javascript source loading time with file_get_content loading time - I would get a somewhat more accurate result than I have now.

I also tried few other methods using curl, javascript, iframes but all of them had problems (unrealistic results or crashes).

Edit: I need to write a script, i know there are many tools available for this (did i mention anywhere im looking for a tool?).

Edit2: Ok, after hours of reasearch i found something that i think might help me - i need to create dom file using http://simplehtmldom.sourceforge.net , then find all javascript elements and get all src from them. I dont know why noone suggested using this earlier.

4

1 回答 1

0

好的,经过数小时的研究,我发现了一些我认为可能对我有帮助的东西——我需要使用http://simplehtmldom.sourceforge.net创建 dom 文件,然后找到所有 javascript 元素并从中获取所有 src。我不知道为什么没有人建议早点使用它。

于 2013-03-08T07:32:21.437 回答