예제 #1
0
        private void RunTests(IPerformance performanceTest, string testName)
        {
            try
            {
                Output += string.Format("Starting performance test for {0}", testName) + Environment.NewLine;

                _watch.Start();

                performanceTest.Registration();

                Output += string.Format("IOC Registration Time for {0} tests: {1} ms", NumberOfTests, _watch.Elapsed.Milliseconds.ToString()) + Environment.NewLine;

                _watch.Restart();

                performanceTest.Resolve();

                Output += string.Format("IOC Resolution Time for {0} tests: {1} ms", NumberOfTests, _watch.Elapsed.Milliseconds.ToString()) + Environment.NewLine;
            }
            finally
            {
                _watch.Stop();

                Output += string.Format("Ending performance test {0}", testName) + Environment.NewLine;
                Output += Environment.NewLine;
            }
        }
        private void RunTests(IPerformance performanceTest, string testName)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();

            try
            {
                Output += string.Format("Starting performance test for {0}", testName) + Environment.NewLine;

                _watch.Start();

                performanceTest.Registration();

                Output += string.Format("Avg. IOC Registration Time for {0} tests: {1} ms", NumberOfTests, ((double)_watch.Elapsed.Milliseconds / (double)NumberOfTests).ToString()) + Environment.NewLine;

                _watch.Restart();

                performanceTest.FirstResolve();

                Output += string.Format("IOC First Resolution Time: {0} ms", _watch.Elapsed.Milliseconds.ToString()) + Environment.NewLine;

                _watch.Restart();

                performanceTest.Resolve();


                Output += string.Format("Total IOC Resolution Time for {0} tests: {1} ms", NumberOfTests, _watch.Elapsed.Milliseconds) + Environment.NewLine;
                Output += string.Format("Avg. IOC Resolution Time for {0} tests: {1} ms", NumberOfTests, ((double)_watch.Elapsed.Milliseconds / (double)NumberOfTests).ToString()) + Environment.NewLine;
            }
            finally
            {
                _watch.Stop();

                Output += string.Format("Ending performance test {0}", testName) + Environment.NewLine;
                Output += Environment.NewLine;
            }
        }