示例#1
0
 public static void Main(string[] args)
 {
     if (false)
     {
         MyStack.Run();
     }
     if (false)
     {
         MyHeap.Run();
     }
     if (false)
     {
         MyUnboxing.Run();
     }
     if (false)
     {
         MyBoxing.Run();
     }
     if (false)
     {
         MyStringConcatination.Run();
     }
     if (false)
     {
         MyStruct.Run();
     }
     if (true)
     {
         MyArray.Run();
     }
 }
示例#2
0
        public static void Run()
        {
            //First run to eliminate any startups overhead.
            MyUnboxing.MeasureA();
            MyUnboxing.MeasureB();

            //Real measurment
            long intDuration = MyUnboxing.MeasureA();
            long objDuration = MyUnboxing.MeasureB();

            //Display the results
            Debug.WriteLine("No unboxing performance: {0} elapsed milliseconds.", intDuration);
            Debug.WriteLine("Unboxing performance: {0} elapsed milliseconds.", objDuration);
            Debug.WriteLine("No unboxing performance is {0} times faster.", objDuration / intDuration);

            /*
             * No unboxing performance: 185 elapsed milliseconds.
             * Unboxing performance: 618 elapsed milliseconds.
             * No unboxing performance is 3 times faster.
             */
        }