How to get REALLY fast benchmarks
I was very excited when I tried this code, it produced amazing performance:
private static void LoadDataFor(string searchPattern) { foreach (var file in Directory.GetFiles("Docs", searchPattern).OrderBy(x=>x)) { var sp = Stopwatch.StartNew(); var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8080/bulk_docs"); httpWebRequest.Method = "POST"; using(var requestStream = httpWebRequest.GetRequestStream()) { var readAllBytes = File.ReadAllBytes(file); requestStream.Write(readAllBytes, 0, readAllBytes.Length); } Console.WriteLine("{0} - {1}", Path.GetFileName(file), sp.Elapsed); } }
Can you figure out what the fatal flaw in this code is?

Comments
Comment preview