代码质量
- 运行时间
- 垃圾回收GC Alloc
- Unity 低效率方法
- Unity 组件访问器
- Profiler 定位性能热点
- 运行时间
public class TimeSpanManager : Singleton<TimeSpanManager>
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
public void Start()
{
watch.Reset();
watch.Start();
}
public void Stop(string tag)
{
watch.Stop();
TimeSpan time = watch.Elapsed;
Debug.LogError(tag+"总毫秒数:"+time.TotalMilliseconds);
}
}
2.垃圾回收GC Alloc
检测GC频繁的代码
3.Unity 低效率方法
SendMessage()
4.Unity 组件访问器
this.transform、this.gameObject、this.rigidbody
5.Profiler 定位性能热点
Profiler.BeginSample()和Profiler.EndSample()