public void InvokeMethodWithoutLoad() { var obj = new ReflectorPerformance(); var method = obj.GetType().GetMethod("InvokeWithoutLoad"); var param = new object[] { 10, 100 }; for (int count = 100; count <= 1000000; count *= 10) { CodeTimer.Time("直接调用", count, obj.InvokeWithoutLoad); CodeTimer.Time("反射调用", count, () => method.Invoke(obj, null)); } }
public void InvokeMethod() { var obj = new ReflectorPerformance(); var method = obj.GetType().GetMethod("Invoke"); var param = new object[] { 10, 100 }; for (int count = 100; count <= 1000000; count *= 10) { CodeTimer.Time("直接调用", count, () => obj.Invoke(10, 100)); CodeTimer.Time("反射调用", count, () => method.Invoke(obj, param)); } }