示例#1
0
        private static void PerformanceTest(IFoo proxy, IFoo original, int loop1)
        {
            Stopwatch stopwatch = new Stopwatch();
            int       result    = 0;

            stopwatch.Start();
            for (int i = loop1 - 1; i >= 0; i--)
            {
                for (int j = loop1 - 1; j >= 0; j--)
                {
                    result += original.BarMethod(1);
                }
            }
            stopwatch.Stop();
            Console.WriteLine("Original result " + result + " took " + stopwatch.ElapsedTicks);
            stopwatch.Reset();

            result = 0;
            stopwatch.Start();
            for (int i = loop1 - 1; i >= 0; i--)
            {
                for (int j = loop1 - 1; j >= 0; j--)
                {
                    result += proxy.BarMethod(1);
                }
            }
            stopwatch.Stop();
            Console.WriteLine("Proxy result " + result + " took " + stopwatch.ElapsedTicks);
            stopwatch.Reset();
        }