public static void DisplayMemoryStats() { using (Process process = Process.GetCurrentProcess()) { if (!process.HasExited) { process.Refresh(); string memoryStats = $"{process.ProcessName} - Memory Stats\n" + $"-------------------------------------\n" + $" Physical memory usage : {MyUtils.ConvertBytesToHumanReadable(process.WorkingSet64)}\n" + $" Paged system memory size : {MyUtils.ConvertBytesToHumanReadable(process.PagedSystemMemorySize64)}\n" + $" Paged memory size : {MyUtils.ConvertBytesToHumanReadable(process.PagedMemorySize64)}\n"; Beaprint.PrintDebugLine(memoryStats); } } }
public static void Run(Action action, bool isDebug, string description = null) { if (!isDebug) { action(); } else { var timer = new Stopwatch(); timer.Start(); action(); timer.Stop(); TimeSpan timeTaken = timer.Elapsed; string descriptionText = string.IsNullOrEmpty(description) ? string.Empty : $"[{description}] "; string log = $"{descriptionText}Execution took : {timeTaken.Minutes:00}m:{timeTaken.Seconds:00}s:{timeTaken.Milliseconds:000}"; Beaprint.PrintDebugLine(log); } }