public override object Clone() { TaskSequence res = (TaskSequence)base.Clone(); res.tasks = new List<PerfTask>(); for (int i = 0; i < tasks.Count; i++) { res.tasks.Add((PerfTask)tasks[i].Clone()); } return res; }
public TaskSequence(PerfRunData runData, String name, TaskSequence parent, bool parallel) : base(runData) { collapsable = (name == null); name = (name != null ? name : (parallel ? "Par" : "Seq")); SetName(name); SetSequenceName(); this.parent = parent; this.parallel = parallel; tasks = new List <PerfTask>(); logByTimeMsec = runData.Config.Get("report.time.step.msec", 0); }
// update state regarding exhaustion. private void UpdateExhausted(PerfTask task) { if (task is ResetInputsTask) { exhausted = false; resetExhausted = true; } else if (task is TaskSequence) { TaskSequence t = (TaskSequence)task; if (t.resetExhausted) { exhausted = false; resetExhausted = true; t.resetExhausted = false; } else { exhausted |= t.exhausted; } } }
private int DoParallelTasks() { TaskStats stats = RunData.Points.CurrentStats; InitTasksArray(); ParallelTask[] t = runningParallelTasks = new ParallelTask[repetitions * tasks.Count]; // prepare threads int index = 0; for (int k = 0; k < repetitions; k++) { for (int i = 0; i < tasksArray.Length; i++) { PerfTask task = (PerfTask)(tasksArray[i].Clone()); t[index++] = new ParallelTask(this, task); } } // run threads StartThreads(t); if (Stop) { foreach (ParallelTask task in t) { task.Task.StopNow(); } } // wait for all threads to complete int count = 0; for (int i = 0; i < t.Length; i++) { t[i].Join(); count += t[i].Count; if (t[i].Task is TaskSequence) { TaskSequence sub = (TaskSequence)t[i].Task; if (sub.countsByTime != null) { if (countsByTime == null) { countsByTime = new int[sub.countsByTime.Length]; } else if (countsByTime.Length < sub.countsByTime.Length) { countsByTime = ArrayUtil.Grow(countsByTime, sub.countsByTime.Length); } for (int j = 0; j < sub.countsByTime.Length; j++) { countsByTime[j] += sub.countsByTime[j]; } } } } if (countsByTime != null) { stats.SetCountsByTime(countsByTime, logByTimeMsec); } // return total count return(count); }
public ParallelTask(TaskSequence outerInstance, PerfTask task) { this.outerInstance = outerInstance; this.task = task; }