using ET; using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using UnityEngine; public class TestExcel : MonoBehaviour { public class AClass { public string Value; public static void TestMethod(string args) { Log.Info(args); } } private Action action; void Start() { object instance = null; Type type = typeof(AClass); var info = type.GetMethod("TestMethod"); action = info.CreateDelegate(typeof(Action), instance) as Action; for (int i = 0; i < 10; i++) { //Stopwatch stw1 = new Stopwatch(); //stw1.Start(); //for (int j = 0; j < 1000; j++) //{ // action?.Invoke("test"); //} //stw1.Stop(); //Log.Info($"委托调用时间:{stw1.ElapsedMilliseconds}"); } object[] args = { "test" }; for (int i = 0; i < 10; i++) { Stopwatch stw1 = new Stopwatch(); stw1.Start(); for (int j = 0; j < 1000; j++) { info.Invoke(instance, args); } stw1.Stop(); Log.Info($"直接调用时间:{stw1.ElapsedMilliseconds}"); } } void Update() { } }