コード例 #1
0
        private static IEnumerable <TestResult> GetResult(TestArguments arguments)
        {
            //Prepare data
            var blockCollection = new BlockCollection <int>();

            for (int i = 0; i < BlockCount; i++)
            {
                blockCollection.Add(GetFilledBlock(ElementsInBlockCount));
            }

            var blockStructure = new ArrayMap <int>(new FixedBalancer(), blockCollection);

            //Prepare measure engine
            var method = GetMethodInfo(arguments.MethodName);

            foreach (var currentCount in arguments.TestCountArray)
            {
                List <object> argumentList = new List <object> {
                    blockStructure, currentCount
                };

                //Get middle estimation of several times calling
                long timeOfAllInvoketionsMs = 0;
                int  countOfInvokations     = 3;

                for (int i = 0; i < countOfInvokations; i++)
                {
                    timeOfAllInvoketionsMs += MeasureEngine.MeasureStaticMethod(method, argumentList);
                }

                yield return(new TestResult(currentCount, timeOfAllInvoketionsMs / countOfInvokations));
            }
        }
コード例 #2
0
        private IEnumerable <TestResult> GetResult(string methodName, CallFlag flag, int[] testCountArray = null)
        {
            if (testCountArray == null)
            {
                testCountArray = new[] { DEFAULT_LIST_SIZE }
            }
            ;

            MethodInfo method = GetMethodInfoOfTestEngine(methodName);

            foreach (int currentCount in testCountArray)
            {
                List <object> argumentList = new List <object> {
                    currentCount
                };
                if (_usingReflectionMethods.ContainsKey(methodName))
                {
                    argumentList.Add(_usingReflectionMethods[methodName]);
                }

                //Get middle estimation of several times calling
                long timeOfAllInvoketionsMs = 0;
                int  countOfInvokations     = 3;

                for (int i = 0; i < countOfInvokations; i++)
                {
                    if (flag == CallFlag.ClearTestCollection)
                    {
                        ClearList();
                    }
                    if (flag == CallFlag.FillTestCollection)
                    {
                        FillList();
                    }

                    timeOfAllInvoketionsMs += MeasureEngine.MeasureMethod(this, method, argumentList);
                }

                yield return(new TestResult(currentCount, timeOfAllInvoketionsMs / countOfInvokations));
            }
        }