/// <summary> /// Measures the subject and also raises the needed events. /// The additional values are calculated from the measured data. /// </summary> /// <returns>A <see cref="KinokoResult"/> object containing the measured data.</returns> /// <param name='task'>The kinoko task to be run.</param> /// <param name='repeatCount'>The number of times to repeat the measurement.</param> private KinokoResult RunTaskAndRaiseEvents(KinokoTask task, int repeatCount) { OnTaskRunning(new TaskRunningEventArgs(task)); KinokoResult result = RunTask(task, repeatCount); OnTaskRun(new TaskRunEventArgs(result)); return(result); }
/// <summary> /// Runs the subject multiple times and measures the time intervals spent. /// </summary> /// <returns>A <see cref="KinokoResult"/> containing the measuremets.</returns> public KinokoResult Run() { KinokoResult result = new KinokoResult(); for (int i = 0; i < repeatCount; i++) { double milliseconds = PerformMeasurementAndRaiseEvents(i); result.AddMeasurement(milliseconds); } return(result); }
/// <summary> /// Measures the time spent to run the subjects received from the subjectProvider. /// </summary> /// <param name="tasksProvider">Provides a list of kinoko tasks to be run.</param> /// <param name="repeatCount">Specifies the number of times to repeat the measurement.</param> /// <returns>A list of <see cref="KinokoResult"/> objects containing the measured data and the calculated values.</returns> /// <exception cref="ArgumentNullException">Is thrown when the subjectProvider or the repeatCount are <see langword="null" />.</exception> /// <exception cref="ArgumentOutOfRangeException">Is thrown when the repeatCount is less then 1.</exception> public IList <KinokoResult> Run(ITasksProvider tasksProvider, int repeatCount) { if (tasksProvider == null) { throw new ArgumentNullException("tasksProvider"); } if (repeatCount < 1) { throw new ArgumentOutOfRangeException("repeatCount", "The repeat count should be an integer greater then 0."); } IEnumerable <KinokoTask> tasks = tasksProvider.GetKinokoTasks(); List <KinokoResult> results = new List <KinokoResult>(); foreach (KinokoTask task in tasks) { KinokoResult result = RunTaskAndRaiseEvents(task, repeatCount); results.Add(result); } return(results); }
/// <summary> /// Initializes a new instance of the <see cref="TaskRunEventArgs"/> class. /// </summary> /// <param name="result">The result produced after the measurement.</param> public TaskRunEventArgs(KinokoResult result) { this.result = result; }