Qui di seguito è un piccolo set di dati da cui sto cercando di rispondere a due domande:Come si può approssimare il tempo di connessione proxy per una richiesta cURL utilizzando i valori CURLINFO _ * _ TIME?
- Quanto tempo ha il proxy vuole per connettersi al server API?
- Quanto tempo ha richiesto la richiesta dell'API per tornare?
Il codice di base si presenta così:
$c = curl_init(); // assume all options set correctly
$time = microtime(true);
$response = curl_exec($c);
$curl_info = curl_getinfo($c); // Returns each `*_TIME` field
$response_time = microtime(true)-$time; // Returns total PHP execution time
Da quanto sopra costruisco questo:
id response_time NAMELOOKUP_TIME CONNECT_TIME APPCONNECT_TIME PRETRANSFER_TIME STARTTRANSFER_TIME REDIRECT_TIME TOTAL_TIME
1 0.250691 0.000191 0.025070 NULL 0.181040 0.250239 0.000000 0.250306
2 0.958577 0.000129 0.022764 NULL 0.136846 0.664099 0.000000 0.957881
3 0.578614 0.000053 0.021111 NULL 0.127998 0.44.000000 0.577812
quanto tempo è stato speso per delega vs. richiesta API per ciascuno dei sopra ?
Il cURL Documentation è utile ma non sono sicuro di come rispondere alle mie domande di cui sopra con relativa sezione dalla documentazione:
TOTAL_TIME Total time of previous transfer.
NAMELOOKUP_TIME Time from start until name resolving completed.
CONNECT_TIME Time from start until remote host or proxy completed.
APPCONNECT_TIME Time from start until SSL/SSH handshake completed.
PRETRANSFER_TIME Time from start until just before the transfer begins.
STARTTRANSFER_TIME Time from start until just when the first byte is received.
REDIRECT_TIME Time taken for all redirect steps before the final transfer.
Il grafico incluso è utile per vedere come questi tempi stack up :
Ma non sono ancora sicuro di quale attribuire il tempo di connessione proxy. Ecco la stessa tabella con i miei commenti:
|
|--NAMELOOKUP // DNS, clearly not proxy. Also insignificant values.
|--|--CONNECT // Does this count toward Proxy Time?
|--|--|--APPCONNECT // Not set (likely due to non-https transaction)
|--|--|--|--PRETRANSFER // Does this count toward Proxy Time?
|--|--|--|--|--STARTTRANSFER // Stop proxy time? So Proxy Time = STARTTRANSFER?
|--|--|--|--|--|--TOTAL // Would TOTAL-STARTRANSFER = API Request Time?
|--|--|--|--|--|--REDIRECT // Always 0 (???)
Ecco una chart di come HTTP Proxy lavoro. Dove si collocano gli elementi CURLINFO _ * _ TIME sopra in questo grafico?