I have a question regarding the performance of the .Net HttpWebRequest client (or WebClient, gives similar results).
If I use HttpWebRequest to request an html page
What's the breakdown of that 1.7s? I suspect you are measuring the entire process?
Using this piece of code I get about 200ms in average:
var request = (HttpWebRequest)WebRequest.Create("http://www.bbc.co.uk/news/");
var stopwatch = new Stopwatch();
stopwatch.Start();
using (var response = (HttpWebResponse)request.GetResponse())
{
stopwatch.Stop();
Console.WriteLine("Elapsed: {0}ms", stopwatch.ElapsedMilliseconds);
var responseStream = response.GetResponseStream();
if (responseStream != null)
using (var sr = new StreamReader(responseStream))
Console.WriteLine("Title: {0}", Regex.Match(sr.ReadToEnd(), @"title>(.*)
Edit changed the code just to measure the actual HTTP request and tried again using Fiddler as well:
Program above: Elapsed: 78ms
Fiddler: Overall Elapsed: 00:00:00.0620000