获取某个方法执行的时间

System.Diagnostics;

Stopwatch sw = new Stopwatch();

sw.Start();
TestMethod();
sw.Stop();
UnityEngine.Debug.Log(string.Format("total: {0} ms",sw.ElapsedMilliseconds));
原文地址:https://www.cnblogs.com/AlanCheng/p/5534584.html