Alex Rivera | Logout

Check response time with HTTPWebRequest?

Asked 2011-10-25T18:17:00.883
13

I'm trying to find the performance of some of my proxies. I tried the Ping class in .net but it does not accept ports. Is there a way to check how long a response took with httpwebrequest?

Edit
Report

1 Answer

19

Why not just time it from the client side?

WebRequest request = BuildRequest();
Stopwatch sw = Stopwatch.StartNew();
using (WebResponse response = request.GetResponse())
{
    // Potentially fetch all the data here, in case it's streaming...
}
sw.Stop();
Console.WriteLine("Request took {0}", sw.Elapsed);
answered 2011-10-25T18:20:20.620

Your Answer