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()); } }
/// <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); }
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(); }
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(); }