Files
SPT-Server-Build/Libraries/SPTarkov.Server.Core/Utils/TimerUtil.cs
T
2025-06-28 12:53:21 +01:00

30 lines
585 B
C#

using System.Diagnostics;
using SPTarkov.DI.Annotations;
namespace SPTarkov.Server.Core.Utils;
[Injectable]
public class TimerUtil
{
protected readonly Stopwatch _stopwatch;
public TimerUtil()
{
_stopwatch = new Stopwatch();
_stopwatch.Start();
}
public int Stop(string unit = "sec")
{
_stopwatch.Stop();
var timePassed = _stopwatch.Elapsed;
return unit switch
{
"ns" => timePassed.Nanoseconds,
"ms" => timePassed.Milliseconds,
_ => timePassed.Seconds,
};
}
}