using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace Performance { class Program { delegate int Add(int a, int b); static Add myDelegate; const int LOOP_COUNT = 100000000; static void Main(string[] args) { myDelegate = new Add(TestAdd); IOrz orz = new Orz(); Stopwatch st = new Stopwatch(); st.Start(); for (int i = 0; i < LOOP_COUNT; i++) { int c = orz.DoIt(1, 2); } st.Stop(); Console.WriteLine(" Call Interface Elapsed time:{0} ms", st.ElapsedMilliseconds); st.Reset(); st.Start(); for (int i = 0; i < LOOP_COUNT; i++) { int d = myDelegate(3, 5); } st.Stop(); Console.WriteLine("Call Delegate Elapsed time :{0} ms", st.ElapsedMilliseconds); Console.ReadLine(); } static int TestAdd(int a, int b) { int c = a + b; return c; } } }