Example #1
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 #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);
        }