Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsPerformanceCounter.cs
2022-06-19 11:50:51 -03:00

36 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Barotrauma
{
public class LuaCsPerformanceCounter
{
public bool EnablePerformanceCounter = false;
public double UpdateElapsedTime;
public Dictionary<string, Dictionary<string, double>> HookElapsedTime = new Dictionary<string, Dictionary<string, double>>();
public static float MemoryUsage
{
get
{
Process proc = Process.GetCurrentProcess();
float memory = MathF.Round(proc.PrivateMemorySize64 / (1024 * 1024), 2);
proc.Dispose();
return memory;
}
}
public void SetHookElapsedTicks(string eventName, string hookName, long ticks)
{
if (!HookElapsedTime.ContainsKey(eventName))
{
HookElapsedTime[eventName] = new Dictionary<string, double>();
}
HookElapsedTime[eventName][hookName] = (double)ticks / Stopwatch.Frequency;
}
}
}