Skip to content

Commit

Permalink
- Removing CPU and RAM utilization logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Olivo committed Nov 9, 2024
1 parent a793acf commit 8424fd3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
5 changes: 0 additions & 5 deletions MixItUp.Base/ChannelSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,6 @@ await StreamingPlatforms.ForEachPlatform(async (p) =>
{
await ChannelSession.SaveSettings();
sessionBackgroundTimer = 0;

int cpuUsage = await ServiceManager.Get<IProcessService>().GetCPUUsage();
int memoryUsage = (int)Math.Round(ServiceManager.Get<IProcessService>().GetMemoryUsage() / 1024 / 1024);
long gcMemory = GC.GetTotalMemory(true);
Logger.ForceLog(LogLevel.Debug, $"Application Usage: {cpuUsage}% CPU Usage - {memoryUsage} MBs of Memory - {gcMemory} Garbage Collector Memory");
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions MixItUp.Base/Services/IProcessService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

namespace MixItUp.Base.Services
{
public interface IProcessService
{
Task<int> GetCPUUsage();

float GetMemoryUsage();

void LaunchLink(string url);

void LaunchFolder(string folderPath);
Expand Down
34 changes: 0 additions & 34 deletions MixItUp.WPF/Services/WindowsProcessService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,11 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;

namespace MixItUp.WPF.Services
{
public class WindowsProcessService : IProcessService
{
public async Task<int> GetCPUUsage()
{
try
{
var startTime = DateTime.UtcNow;
var startCpuUsage = Process.GetCurrentProcess().TotalProcessorTime;

await Task.Delay(500);

var endTime = DateTime.UtcNow;
var endCpuUsage = Process.GetCurrentProcess().TotalProcessorTime;

var cpuUsedMs = (endCpuUsage - startCpuUsage).TotalMilliseconds;
var totalMsPassed = (endTime - startTime).TotalMilliseconds;

var cpuUsageTotal = cpuUsedMs / (Environment.ProcessorCount * totalMsPassed);

return (int)Math.Round(cpuUsageTotal * 100);
}
catch (Exception ex) { Logger.Log(ex); }
return 0;
}

public float GetMemoryUsage()
{
try
{
return Process.GetCurrentProcess().WorkingSet64;
}
catch (Exception ex) { Logger.Log(ex); }
return 0;
}

public void LaunchLink(string url)
{
try
Expand Down

0 comments on commit 8424fd3

Please sign in to comment.