HTTP Performance Test in C# I wrote a script to test how long it takes to make requests against a url.  It takes a list of urls, an array of concurrent requests, and a number of times to attempt the test.  How could I improve on this?

//https://www.nuget.org/packages/RestSharp

string baseUrl = "http://localhost";
void Main()
{
    var urls = new string[] { 
        "/some/end/point",
    };

    var concurrentRequests = new int[]{ 1, 5, 25, 50, 100, 500, 1000};
    var numberOfTurns = 10;
    RunTests(urls, concurrentRequests, numberOfTurns);

}

private void RunTests(string[] urls, int[] concurrentRequests,  int numberOfTimes = 1)
{
    for(var i = 0; i &lt; numberOfTimes; i++)
    {
        RunFor(urls, concurrentRequests);
    }
}
private void RunFor(string[] urls, int[] concurrentRequests)
{
    concurrentRequests.ToList().ForEach( e =&gt;   
    {
         RunTest(urls, e);
    }); 
}
private void RunTest(string[] sites, int iterations, string description = "")
{
    var action = GetAction();

    var watch = new Stopwatch(); 
   // Construct started tasks
   Task&lt;bool&gt;[] tasks = new Task&lt;bool&gt;[sites.Count()];
   watch.Start();

   for(int j = 0; j &lt; iterations; j++)
   {
        for (int i = 0; i &lt; sites.Count(); i++)
        {
            tasks[i] = Task&lt;bool&gt;.Factory.StartNew(action, sites[i]);
        }
   }
   try
   {
       Task.WaitAll(tasks);
   }
   catch (AggregateException e)
   {
       Console.WriteLine("\nThe following exceptions have been thrown by WaitAll()");
       for (int j = 0; j &lt; e.InnerExceptions.Count; j++)
       {
           Console.WriteLine("\n-------------------------------------------------\n{0}", e.InnerExceptions[j].ToString());
       }
   }
   finally
   {
    watch.Stop();
    Console.WriteLine("\"{0}|{1}|{2}\", ",sites.Count(), iterations, watch.Elapsed.TotalSeconds);
   }
}
private Func&lt;object, bool&gt;  GetAction()
{
    baseUrl = baseUrl.Trim('/');
    return (object obj) =&gt;
   {
        var str = (string)obj;
        var client = new RestClient(baseUrl);
        client.Authenticator = new NtlmAuthenticator();
        var request = new RestRequest(str, Method.GET);
        request.AddHeader("Accept", "text/html");
        var response = client.Execute(request);     
        return (response != null);
   };
}
You're not always using var in what I think of as a good way. We should only use the keyword when it's obvious what type the variable is. Consider this line.


Task&lt;bool&gt;[] tasks = new Task&lt;bool&gt;[sites.Count()];



It's completely obvious what tasks is because you're newing it up right there on that line. There's no reason not to simplify by using var. 

But here, you have the opposite problem. 


var response = client.Execute(request);     



It is not obvious what the return type is, so you shouldn't be using var.