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(); } }
public static void Run() { //First run to eliminate any startups overhead. MyBoxing.MeasureA(); MyBoxing.MeasureB(); //Real measurment long intDuration = MyBoxing.MeasureA(); long objDuration = MyBoxing.MeasureB(); //Display the results Debug.WriteLine("No boxing performance: {0} elapsed milliseconds.", intDuration); Debug.WriteLine("Boxing performance: {0} elapsed milliseconds.", objDuration); Debug.WriteLine("No boxing performance is {0} times faster.", objDuration / intDuration); /* * No boxing performance: 330 elapsed milliseconds. * Boxing performance: 764 elapsed milliseconds. * No boxing performance is 2 times faster. */ }