Have you been testing code speed like this?
var start = DateTime.Now;
for(i = 0; i < 1000; i++)
var stop = DateTime.Now;
var total = stop - start;
var timePerIteration = total.Ticks / i;
Or maybe you’ve found the Stopwatch class and been happy with its superior time precision?
Better, I’d say, but I’ve quite had it. Plus I needed to benchmark a local website and needed to test parallel requests (something similar to ab – ApacheBench)
What does a programmer in such a case? Writes his own tools! That’s how BenchmarkNET appeared. Using BenchmarkNET you can write the same thing as above only much shorter and with a better timing precision :
var result = Benchmark.Sequentially(() => DoSomething(), 1000);
Neat? That’s not all. The result can easily printed out to a console or inspected with a debugger :
Benchmarking an HTTP operation over 10 parallel threads, 100 times for each thread?
var dl2 = Benchmark.Parallel(new BenchmarkParams<WebClient>(c => c.DownloadString("http://localhost/"), 100), 10, () => new WebClient());
The project has been published as open source (LGPL license) on CodePlex. You can discuss it, file bugs, or even contribute to it.
Have fun and if you test it out, please leave some feedback!
Later edit : It seems some people already dig it