예제 #1
0
        public static void GC()
        {
            int sum = 0;

            for (int n = 0; n < nTests; n++)
            {
                for (int i = 0; i < perfArray.Length; i++)
                {
                    perfArray [i] = "abcdefg" + i.ToString() + n.ToString();
                    int s1 = PerformanceTest.InternalCount(perfArray, i);
                    sum += s1;
                }
            }
        }
예제 #2
0
        public static void Performance()
        {
            int s   = PerformanceTest.ManagedCount(perfArray, 0);
            int sum = 0;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int n = 0; n < nTests; n++)
            {
                for (int i = 0; i < perfArray.Length; i++)
                {
                    int s1 = PerformanceTest.ManagedCount(perfArray, i);
                    sum += s1;
                }
            }
            sw.Stop();

            Console.WriteLine("Managed char count={0} ms", sw.ElapsedMilliseconds);

            s = PerformanceTest.InternalCount(perfArray, 0);
            if (!PerformanceTest.Validate(perfArray, PerformanceTest.InternalCount))
            {
                throw new ArgumentException("Wrong algorithm implementation");
            }

            sum = 0;
            sw.Restart();
            for (int n = 0; n < nTests; n++)
            {
                for (int i = 0; i < perfArray.Length; i++)
                {
                    int s1 = PerformanceTest.InternalCount(perfArray, i);
                    sum += s1;
                }
            }
            sw.Stop();

            Console.WriteLine("Internal char count={0} ms", sw.ElapsedMilliseconds);
        }