Unity3D之獲取某個方法執行的時間

using UnityEngine;
using System.Collections;
using System.Diagnostics;

public class NewBehaviourScript : MonoBehaviour {

    void Start () {

        float t = Time.time;
        TestMethod();
        UnityEngine.Debug.Log(string.Format("total: {0} ms",Time.time - t));



        Stopwatch sw = new Stopwatch();
        sw.Start();
        TestMethod();
        sw.Stop();
        UnityEngine.Debug.Log(string.Format("total: {0} ms",sw.ElapsedMilliseconds));


        Profiler.BeginSample("TestMethod");
        TestMethod();
        Profiler.EndSample();
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章