Address Feedback

This commit is contained in:
sunshineinabox 2023-07-06 20:24:25 -07:00
parent 00fee4715e
commit 44ede2c6b8
2 changed files with 5 additions and 8 deletions

View file

@ -105,6 +105,7 @@ namespace ARMeilleure.Translation
public void Execute(State.ExecutionContext context, ulong address) public void Execute(State.ExecutionContext context, ulong address)
{ {
int physicalCoreCount = SystemInfo.GetPhysicalCoreCount(); int physicalCoreCount = SystemInfo.GetPhysicalCoreCount();
if (Interlocked.Increment(ref _threadCount) == 1) if (Interlocked.Increment(ref _threadCount) == 1)
{ {
IsReadyForTranslation.WaitOne(); IsReadyForTranslation.WaitOne();

View file

@ -94,17 +94,11 @@ namespace Ryujinx.Common.SystemInfo
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ {
string cpuCoresLine = File.ReadLines("/proc/cpuinfo") string cpuCoresLine = File.ReadLines("/proc/cpuinfo").FirstOrDefault(line => line.Contains("cpu cores"));
.FirstOrDefault(line => line.Contains("cpu cores"));
if (cpuCoresLine != null) if (cpuCoresLine != null)
{ {
string[] parts = cpuCoresLine.Split(':'); string[] parts = cpuCoresLine.Split(':');
if (parts.Length == 2 && int.TryParse(parts[1].Trim(), out int cores))
{
coreCount = cores;
Console.WriteLine("Number of physical cores: " + coreCount);
}
} }
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
@ -122,13 +116,15 @@ namespace Ryujinx.Common.SystemInfo
}; };
process.Start(); process.Start();
coreCount = int.Parse(process.StandardOutput.ReadToEnd()); coreCount = int.Parse(process.StandardOutput.ReadToEnd());
process.WaitForExit(); process.WaitForExit();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("An error occurred while trying to get the physical core count: " + ex.Message); Logger.Error?.Print(LogClass.Application,"An error occurred while trying to get the physical core count: {ex.Message}");
} }
return coreCount; return coreCount;