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"); } } }