public void Task_MasterTaskScheduler() { string testName = "Task_MasterTaskScheduler"; var baseline = DoBaseTestRun(testName + "-Baseline", numTasks); var tasks = new List <Task>(numTasks); var masterScheduler = GetTaskScheduler(); TaskScheduler[] schedulers = new TaskScheduler[numTasks]; for (int i = 0; i < numTasks; i++) { schedulers[i] = new TaskSchedulerWrapper(masterScheduler); } QueuedTaskSchedulerTests_Set1.TimeRun(1, baseline, testName, () => { for (int i = 0; i < numTasks; i++) { Task t = CreateTask(i); t.Start(schedulers[i]); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); }); foreach (Task t in tasks) { Assert.IsTrue(t.IsCompleted, "Task is completed"); Assert.IsFalse(t.IsFaulted, "Task did not fault"); Assert.IsNull(t.Exception, "Task did not return an Exception"); } }
public void Task_GroupedMasterTaskScheduler() { const string testNameBase = "Task_GroupedMasterTaskScheduler"; int[] testPoints = new[] { 100, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 100000, 500000 }; foreach (int numSchedulers in testPoints) { string testName = testNameBase + "-" + numSchedulers; int numTasks = numSchedulers * 10; Console.WriteLine(testName + " NumTasks=" + numTasks + " NumSchedulers=" + numSchedulers); // Run baseline test with single, Default scheduler var baseline = TimeRun(1, TimeSpan.Zero, testName + "-Baseline", () => RunTestLoop(numTasks, null)); // Run test with many schedulers... // Pre-create schedulers var masterScheduler = new QueuedTaskScheduler(); TaskScheduler[] schedulers = new TaskScheduler[numSchedulers]; for (int i = 0; i < numSchedulers; i++) { schedulers[i] = new TaskSchedulerWrapper(masterScheduler); } TimeRun(1, baseline, testName, () => RunTestLoop(numTasks, schedulers)); } }
public void Task_GroupedMasterTaskScheduler() { const string testNameBase = "Task_GroupedMasterTaskScheduler"; int[] testPoints = new[] { 100, 500, 1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000, 100000, 500000 }; foreach (int numSchedulers in testPoints) { string testName = testNameBase + "-" + numSchedulers; int numTasks = numSchedulers * 10; output.WriteLine(testName + " NumTasks=" + numTasks + " NumSchedulers=" + numSchedulers); // Run baseline test with single, Default scheduler var baseline = TimeRun(1, TimeSpan.Zero, testName + "-Baseline", output, () => RunTestLoop(numTasks, null)); // Run test with many schedulers... // Pre-create schedulers var masterScheduler = new QueuedTaskScheduler(); TaskScheduler[] schedulers = new TaskScheduler[numSchedulers]; for (int i = 0; i < numSchedulers; i++) { schedulers[i] = new TaskSchedulerWrapper(masterScheduler); } TimeRun(1, baseline, testName, output, () => RunTestLoop(numTasks, schedulers)); } }
public void Task_MasterTaskScheduler() { string testName = "Task_MasterTaskScheduler"; var baseline = DoBaseTestRun(testName + "-Baseline", numTasks); var tasks = new List<Task>(numTasks); var masterScheduler = GetTaskScheduler(); TaskScheduler[] schedulers = new TaskScheduler[numTasks]; for (int i = 0; i < numTasks; i++) { schedulers[i] = new TaskSchedulerWrapper(masterScheduler); } QueuedTaskSchedulerTests_Set1.TimeRun(1, baseline, testName, output, () => { for (int i = 0; i < numTasks; i++) { Task t = CreateTask(i); t.Start(schedulers[i]); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); }); foreach (Task t in tasks) { Assert.IsTrue(t.IsCompleted, "Task is completed"); Assert.IsFalse(t.IsFaulted, "Task did not fault"); Assert.IsNull(t.Exception, "Task did not return an Exception"); } }