Files
aibis-dream/Assets/Scripts/Framework/OtherKit/CodeTimer.cs
T
2026-02-09 14:40:41 +08:00

23 lines
525 B
C#

using System;
using System.Diagnostics;
namespace AibisDream.Framework
{
public class CodeTimer : IDisposable
{
private readonly Stopwatch _stopwatch;
private readonly string _name;
public CodeTimer(string name = "")
{
_name = name;
_stopwatch = Stopwatch.StartNew();
}
public void Dispose()
{
_stopwatch.Stop();
UnityEngine.Debug.Log($"[{_name}] 耗时: {_stopwatch.ElapsedMilliseconds}ms");
}
}
}