private static async Task <TestResults> RunTestAsync( int numClients, ILoadDriver[] loadDrivers, Func <ILoadDriver, Task <TestResults> > runTestOnSingleDriverInstance) { Task <TestResults>[] testTasks = new Task <TestResults> [numClients]; // Trigger the test run for each of the clients and wait for them all // to finish. Also measure how to long it took for all of them to // finish running their tests. Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < numClients; i++) { testTasks[i] = runTestOnSingleDriverInstance(loadDrivers[i]); } await Task.WhenAll(testTasks); stopwatch.Stop(); // Merge the raw results from all of the clients TestResults results = testTasks[0].Result; for (int i = 1; i < numClients; i++) { results = TestResults.Combine(results, testTasks[i].Result); } // Compute averages based on the raw results from the clients. results.ComputeAverages(stopwatch.Elapsed); return(results); }