Example #1
0
        public override void Run()
        {
            try
            {
                // create an instance of the class that defines the test method.
                object targetInstance = _type.GetConstructor(Type.EmptyTypes).Invoke(null);

                SetVariations(targetInstance);

                ExecuteSetupPhase(targetInstance);

                TestMethodDelegate tmd = CreateTestMethodDelegate();

                ExecuteTest(targetInstance, tmd);

                ExecuteCleanupPhase(targetInstance);

                LogTest();
            }
            catch (TargetInvocationException e)
            {
                LogTestFailure(e.InnerException.ToString());
            }
            catch (Exception e)
            {
                LogTestFailure(e.ToString());
            }
        }
Example #2
0
        /// <summary>
        /// Run any per-thread setup needed
        /// </summary>
        public void RunSetup()
        {
            // create an instance of the class that defines the test method.
            if (null == _targetInstance)
            {
                InitTargetInstance();
            }
            _tmd = CreateTestMethodDelegate();

            // Set variation fields on the target instance
            SetVariations(_targetInstance);

            // Execute the setup phase for this thread.
            ExecuteSetupPhase(_targetInstance);
        }
Example #3
0
        private void ExecuteTest(object targetInstance, TestMethodDelegate tmd)
        {
            int warmupIterations = _attr.WarmupIterations;
            int testIterations   = _attr.TestIterations;

            if (_overrideIterations >= 0)
            {
                testIterations = _overrideIterations;
            }
            if (_overrideWarmup >= 0)
            {
                warmupIterations = _overrideWarmup;
            }

            /** do some cleanup to make memory tests more accurate **/
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
            System.GC.Collect();

            IntPtr h    = MemApi.GetCurrentProcess();
            bool   fRes = MemApi.SetProcessWorkingSetSize(h, -1, -1);

            /****/

            System.Threading.Thread.Sleep(10000);

            for (int i = 0; i < warmupIterations; i++)
            {
                tmd(targetInstance);
            }

            TestMetrics.StartCollection();
            for (int i = 0; i < testIterations; i++)
            {
                tmd(targetInstance);
            }
            TestMetrics.StopCollection();
        }
Example #4
0
        private void ExecuteTest(Object targetInstance, TestMethodDelegate tmd)
        {
            int warmupIterations = _attr.WarmupIterations;
            int testIterations = _attr.TestIterations;

            if (_overrideIterations >= 0)
            {
                testIterations = _overrideIterations;
            }
            if (_overrideWarmup >= 0)
            {
                warmupIterations = _overrideWarmup;
            }

            /** do some cleanup to make memory tests more accurate **/
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();
            System.GC.Collect();

            IntPtr h = MemApi.GetCurrentProcess();
            bool fRes = MemApi.SetProcessWorkingSetSize(h, -1, -1);
            /****/

            System.Threading.Thread.Sleep(10000);

            for (int i = 0; i < warmupIterations; i++)
            {
                tmd(targetInstance);
            }

            TestMetrics.StartCollection();
            for (int i = 0; i < testIterations; i++)
            {
                tmd(targetInstance);
            }
            TestMetrics.StopCollection();
        }
Example #5
0
        /// <summary>
        /// Run any per-thread setup needed
        /// </summary>
        public void RunSetup()
        {
            // create an instance of the class that defines the test method.
            if (null == _targetInstance)
            {
                InitTargetInstance();
            }
            _tmd = CreateTestMethodDelegate();

            // Set variation fields on the target instance
            SetVariations(_targetInstance);

            // Execute the setup phase for this thread.
            ExecuteSetupPhase(_targetInstance);
        }