We are working in a Tool that measures performance of web sites in a not intrusive way (not modifying the web site source code). We have a small application in Java that fires request over the internet to our customer web sites and save the ResponseCode, LoadTime, Amount Of Bytes Loaded, etc.
One of the main metrics we measure is the TTFB. I wonder if we are doing that the right way.
We do a HttpURLConnection and save the difference of two time stamps as TTFB like bellow.
Calendar before = Calendar.getInstance();
HttpURLConnection connection = (HttpURLConnection)new URL( url ).openConnection();
connection.getResponseCode();
Calendar end = Calendar.getInstance();
//read the content
Calendar endContent = Calendar.GetInstance();
long TTFB = end.getTimeInMillis() - before().getTimeInMillis();
long justLoadTime = endContent.getTimeInMillis() - end.getTimeInMillis();
It is correct? Getting the time till ResponseCode is the TTFB? Or until that some bytes of content already arrived?
Is there more easy way to get these information?
Not in rare times, the difference between TTFB and justLoadTime is so small, in heavy weight pages.