示例#1
0
        /// <summary>
        /// Runs specified benchmark tasks, the basic benchmarking workflow.
        /// Prepares benchmark, run warming up iterations, measures the execution
        /// time for specified number of benchmarking iterations, and gets the benchmarking results </summary>
        /// <param name="task">  </param>
        public static void runTask(BenchmarkTask task)
        {
            System.Console.WriteLine("Preparing task " + task.Name);
            task.prepareTest();

            System.Console.WriteLine("Warming up " + task.Name);
            for (int i = 0; i < task.WarmupIterations; i++)
            {
                task.runTest();
            }

            System.Console.WriteLine("Runing " + task.Name);
            //task.prepare(); // ovde mozda poziv nekoj reset ili init metodi koja bi randomizovala mrezu, u osnovnoj klasi da neradi nista tako da moze da se redefinise i ne mora

            Stopwatch            timer   = new Stopwatch();
            BenchmarkTaskResults results = new BenchmarkTaskResults(task.TestIterations);

            for (int i = 0; i < task.TestIterations; i++)
            {
                timer.reset();

                timer.start();
                task.runTest();
                timer.stop();

                results.addElapsedTime((long)Math.Round(timer.ElapsedTime.TotalMilliseconds));
            }

            results.calculateStatistics();
            System.Console.WriteLine(task.Name + " results");
            System.Console.WriteLine(results);             // could be sent to file
        }
示例#2
0
 /// <summary>
 /// Adds specified benchmark task </summary>
 /// <param name="task"> benchmark task </param>
 public virtual void addTask(BenchmarkTask task)
 {
     tasks.Add(task);
 }