public static void TestPerf() { //这次测试中文1234 Stopwatch sw = new Stopwatch(); int MaxTimes = 100; TT t = new TT(); MethodInfo mi = t.GetType().GetMethod("Test"); MethodWrapper invoker = new MethodWrapper(t.GetType().GetCustomAttributes(false), true, () => { return new TT(); }, t, mi, mi.GetCustomAttributes(false)); ActionBuilder builder = new ActionBuilder(); builder.RegistType<TT>(); IAction action = builder.FindAction("TT.Test"); ActionContext context = new ActionContext() { Arguments = new object[] { "1", "2" }, oInstance = t }; Test(5, MaxTimes, (i, w) => { string s = string.Empty; switch (i) { case 0: s = "方法直接调用"; break; case 1: s = "动态代理方法调用"; break; case 2: s = "Zata封装方法调用"; break; case 3: s = "反射调用"; break; } Console.WriteLine("{0}: {1}毫秒",s, w.ElapsedMilliseconds); }, i => { t.Test("1", "2"); }, i => invoker.Execute(context), i => { action.Execute(context); }, i => mi.Invoke(t, new object[] { "1", "2"}) ); }