/// <summary> /// 常规调用以及反射调用方法比较 /// </summary> public void TestMethod1() { int count = 1000000; Stopwatch sw = new Stopwatch(); UnitTest2 program = new UnitTest2(); Object[] obj = { new Object(), new Object(), new Object() }; sw.Start(); for (int i = 0; i < count; i++) { Call(obj[0], obj[1], obj[2]); } sw.Stop(); Console.WriteLine("常规调用时间:{0}", sw.ElapsedMilliseconds); MethodInfo mInfo = typeof(UnitTest2).GetMethod("Call"); sw.Start(); for (int i = 0; i < count; i++) { mInfo.Invoke(program, obj); } sw.Stop(); Console.WriteLine("反射调用的时间:{0}", sw.ElapsedMilliseconds); }