I am trying to measure a query using WebRequest,
But Im gets significantly smaller results, and then measures with FireBug.
I suppose, because some materials, such as Images and CSS, are not included.
Is there a way to measure the full web request?
My code is:
public string GetPageHtmlTime(string strUrl) { WebRequest request = null; WebResponse response = null; HttpWebResponse httpCurrentWeResponse = null; try { //making a request to the file. request = WebRequest.Create(strUrl); //set 5 seconds timeout for the request request.Timeout = 5 * 1000; //Stopwatch Stopwatch sw = new Stopwatch(); sw.Start(); //get the server response response = request.GetResponse(); httpCurrentWeResponse = (HttpWebResponse)response; sw.Stop(); //if the http response return any type of failure if (httpCurrentWeResponse.StatusCode != HttpStatusCode.OK || response == null) return "Error: " + httpCurrentWeResponse.StatusCode; response.Close(); //Return time: return "OK time=" + sw.ElapsedMilliseconds.ToString("0,0"); } catch (System.Exception ex) { return "Error: ex=" + ex.Message; } }
source share