Checking response time with HTTPWebRequest

If you want to time the response time of your webrequests/proxies, etc using C# there is a easy way to do it. We need to use a stopwatch object as shown in the example.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myUri);
System.Diagnostics.Stopwatch timer = new Stopwatch();


HttpWebResponse response = (HttpWebResponse)request.GetResponse();
response.Close ();


TimeSpan timeTaken = timer.Elapsed;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.