using System.Collections.Generic;
using System;
public static class PerformanceProfiler
{
private struct PerformancePoint
{
public PerformancePoint(string msg)
{
this.msg = msg;
this.time = DateTime.Now;
}
private string msg;
private DateTime time;
public override string ToString()
{
return string.Format("PerformanceProfiler ****** {0} => {1} ms", string.IsNullOrEmpty(this.msg) ? "Time" : msg, (DateTime.Now - this.time).Ticks/10000.0f);
}
}
private static LinkedList<PerformancePoint> PerformancePoints = new LinkedList<PerformancePoint>();
public static void SetPoint(string msg = null)
{
PerformancePoints.AddLast(new PerformancePoint(msg));
}
public static void GetPoint()
{
if (PerformancePoints.Count > 0)
{
PerformancePoint point = PerformancePoints.Last.Value;
PerformancePoints.RemoveLast();
UnityEngine.Debug.LogWarning(point.ToString());
}
else
{
UnityEngine.Debug.LogWarning("PerformancePoints Empty!!!");
}
}
}
UNITY 用于打点统计的小工具
最新推荐文章于 2024-06-14 16:47:12 发布