From b5cb5c83fa8ce730fd87029ca426a3712c5f8a92 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Sat, 8 Jul 2023 07:45:09 -0700 Subject: [PATCH] Interanlly Cache value so looping continously isn't costly. Only assign physicalCoreCount when needed. --- src/Ryujinx.Common/SystemInfo/SystemInfo.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Ryujinx.Common/SystemInfo/SystemInfo.cs b/src/Ryujinx.Common/SystemInfo/SystemInfo.cs index 4b92b0c9c..05eb7859c 100644 --- a/src/Ryujinx.Common/SystemInfo/SystemInfo.cs +++ b/src/Ryujinx.Common/SystemInfo/SystemInfo.cs @@ -16,6 +16,7 @@ namespace Ryujinx.Common.SystemInfo public ulong RamTotal { get; protected set; } public ulong RamAvailable { get; protected set; } protected static int LogicalCoreCount => Environment.ProcessorCount; + private static int? _cachedPhysicalCoreCount = null; protected SystemInfo() { @@ -80,6 +81,11 @@ namespace Ryujinx.Common.SystemInfo public static int GetPhysicalCoreCount() { + if (_cachedPhysicalCoreCount.HasValue) + { + return _cachedPhysicalCoreCount.Value; + } + int coreCount = Environment.ProcessorCount; 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}"); } + _cachedPhysicalCoreCount = coreCount; + return coreCount; } }