mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-13 14:19:12 +00:00
Interanlly Cache value so looping continously isn't costly. Only assign physicalCoreCount when needed.
This commit is contained in:
parent
f4dbfe890a
commit
b5cb5c83fa
1 changed files with 8 additions and 0 deletions
|
@ -16,6 +16,7 @@ namespace Ryujinx.Common.SystemInfo
|
||||||
public ulong RamTotal { get; protected set; }
|
public ulong RamTotal { get; protected set; }
|
||||||
public ulong RamAvailable { get; protected set; }
|
public ulong RamAvailable { get; protected set; }
|
||||||
protected static int LogicalCoreCount => Environment.ProcessorCount;
|
protected static int LogicalCoreCount => Environment.ProcessorCount;
|
||||||
|
private static int? _cachedPhysicalCoreCount = null;
|
||||||
|
|
||||||
protected SystemInfo()
|
protected SystemInfo()
|
||||||
{
|
{
|
||||||
|
@ -80,6 +81,11 @@ namespace Ryujinx.Common.SystemInfo
|
||||||
|
|
||||||
public static int GetPhysicalCoreCount()
|
public static int GetPhysicalCoreCount()
|
||||||
{
|
{
|
||||||
|
if (_cachedPhysicalCoreCount.HasValue)
|
||||||
|
{
|
||||||
|
return _cachedPhysicalCoreCount.Value;
|
||||||
|
}
|
||||||
|
|
||||||
int coreCount = Environment.ProcessorCount;
|
int coreCount = Environment.ProcessorCount;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -128,6 +134,8 @@ namespace Ryujinx.Common.SystemInfo
|
||||||
Logger.Error?.Print(LogClass.Application,$"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}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cachedPhysicalCoreCount = coreCount;
|
||||||
|
|
||||||
return coreCount;
|
return coreCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue