Unity中精确获取执行时间System.Diagnostics.Stopwatch

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

public class Test : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        for (int i = 0; i < 100; i++)
        {
            UnityEngine.Debug.Log(i);        
        }
        stopwatch.Stop();
        UnityEngine.Debug.Log("ms=" + stopwatch.ElapsedMilliseconds);
    }

}

你可能感兴趣的:(Unity学习)