added PerformanceCounter

This commit is contained in:
Evil Factory
2022-06-19 11:50:51 -03:00
parent 78716f4695
commit 64c81146fb
5 changed files with 61 additions and 16 deletions
@@ -0,0 +1,36 @@
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;
}
}
}