阅读背景:

UNITY 用于打点统计的小工具

来源:互联网 
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!!!");
        }
    }

}
using System.Collections.Generic;
using System;



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: