2013-03-17 26 views
0

我正在嘗試計算一個css/javascript/img網址(例如http://g2.delfi.lt/scms/?g=delfi-fp.css&1362823940)的加載時間。計算css/js/img源碼的加載時間

我試過pingdom,它計算了749ms,我想知道他們是如何計算這個的。這是他們做的(我認爲)的計算:

DNS - 443ms 
Connect - 589ms 
Send - 1ms 
Wait - 152ms 
Receive - 1ms 
Total - 1.19s 

我不明白他們是如何從1.19s獲得0.749s。他們從什麼中減去了什麼?

我試着用捲曲計算加載時間,但它並沒有給我結果我期待爲:

$src_array = array(); 
    foreach ($array as $url1) { 
     $curl1 = curl_init(); 
     curl_setopt($curl1, CURLOPT_URL, $url1); 
     curl_setopt($curl1, CURLOPT_RETURNTRANSFER, TRUE); 
     curl_setopt($curl1, CURLOPT_CONNECTTIMEOUT_MS, 300); 
     curl_setopt($curl1, CURLOPT_TIMEOUT_MS, 300); 
     curl_exec($curl1); //curl ivykdymas 
     $contime1 = curl_getinfo($curl1, CURLINFO_TOTAL_TIME); 
     $src_array[] = $contime1; 
    } 

$gg = (array_sum($src_array)); 

如何計算裝載1具體JS/CSS/IMG源的時間?

+0

您是否正在瀏覽器或服務器上查找加載時間? – MattDiamant 2013-03-17 07:27:31

+0

Pingdom的計算時間爲'Total time' - 'DNS time'。 – fardjad 2013-03-17 07:30:12

+0

@MattDiamant服務器 – Edgar 2013-03-17 07:49:28

回答

0

這是計算。

DNS: 443ms 
Connect: 589ms + Send: 1ms + Wait: 152ms + Receive: 1ms = 743ms 
Total = 1.19s 
Grand total = 1.19s - 443ms = 747ms