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();
}
Unity3D之获取某个方法执行的时间
最新推荐文章于 2024-06-03 18:03:55 发布
本文介绍了一种使用Unity进行性能测试的方法,通过记录不同方法的执行时间来评估性能。文中展示了如何利用Time类、Stopwatch类及Unity的Profiler工具来进行详细的性能分析。
1572

被折叠的 条评论
为什么被折叠?



