/// <summary>
        /// Called when starting.
        /// </summary>
        /// <returns>
        /// An asynchronous task
        /// </returns>
        public IEnumerable <BenchmarkResult> Run()
        {
            List <BenchmarkResult> results = new List <BenchmarkResult>();

            foreach (BenchmarkContainerType containerType in this.configuration.ContainerTypes)
            {
                foreach (long cardinality in this.configuration.Cardinalities)
                {
                    int[] containerData = Utilities.GetSlice(this.data, cardinality);

                    IBenchmarkContainer <int> container = BenchmarkContainerFactory <int> .CreateBenchmarkContainer(containerType, containerData);

                    BenchmarkResult result = this.runner.GetResult(container);
                    results.Add(result);
                }
            }

            return(results);
        }
Exemple #2
0
        /// <summary>
        /// Gets the results.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns>A benchmark result</returns>
        public BenchmarkResult GetResult(IBenchmarkContainer <int> container)
        {
            BenchmarkResult result = new BenchmarkResult(container.Type, container.Cardinality);

            int operationIndex = 0;

            foreach (KeyValuePair <BenchmarkOperation, int> kvp in this.configuration.Operations)
            {
                Action <int> action = this.GetAction(container, kvp.Key);

                this.stopWatch.Restart();
                for (int iterationIndex = 0; iterationIndex < (kvp.Value * this.configuration.TestIterationCountScalar); iterationIndex++)
                {
                    action(this.testValues[operationIndex + iterationIndex]);
                }
                this.stopWatch.Stop();

                result.Record(kvp.Key, this.scoringStrategy.Score(this.stopWatch.ElapsedMilliseconds));
                operationIndex++;
            }

            return(result);
        }