I donβt think there is any way to accurately calculate what you are looking for.
cURL connects to the proxy, sends a request and waits for a response. Everything the proxy does in time (it has DNS resolution, connects to the host, sends (proxies) the request, waits for a response, reads the response and proxies it back - this is a black box for cURL.
There is no way to find out how long any of these steps have been taken individually solely from the HTTP / SOCKS proxy.
The only thing you can know for sure is the sum of all these actions ( CURLINFO_TOTAL_TIME - CURLINFO_STARTTRANSFER_TIME ). I suppose it would be possible that there might be a slight delay from the moment the proxy completes the request, when cURL gets the first byte back (maybe caching?).
Another possibility that I'm not entirely sure of (it may depend on the proxy configuration and response headers sent by the API) is when the proxy server really sends the data back. You may need to download the entire HTTP response, or it may start sending headers and data as they read. This can lead to some potentially significant differences in your calculations.
Ultimately, I believe that the main reason is that you do not have data about the connection to the proxy server, there is no way to find out or determine exactly how long the proxy connection to the API has been accepted, and how long it took to get the response. Otherwise, you are right that TOTAL - STARTTRANSFER is your best approximation for response time if you use a proxy.
Not knowing exactly what you are trying to do or why, it might be best to rent some VPS or cloud instances at different geographical locations to run some PHP instances using cURL to connect directly to the API so that you have access to all metrics which you are looking for.
drew010
source share