mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
More detailed system stats
Fixed physical core count always returning logical core count (this engine does not run on the AMD Phenom processor).
This commit is contained in:
parent
ecfc380f84
commit
1e7b746356
@ -114,7 +114,7 @@
|
||||
void Systems_Init()
|
||||
{
|
||||
spdlog::info("+-------------------------------------------------------------+\n");
|
||||
QueryCPUInfo();
|
||||
QuerySystemInfo();
|
||||
CFastTimer initTimer;
|
||||
|
||||
initTimer.Start();
|
||||
@ -343,7 +343,7 @@ void WS_Shutdown()
|
||||
std::cerr << "Failed to stop winsock via WSACleanup: (" << NET_ErrorString(WSAGetLastError()) << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
void QueryCPUInfo()
|
||||
void QuerySystemInfo()
|
||||
{
|
||||
const CPUInformation& pi = GetCPUInformation();
|
||||
|
||||
@ -355,17 +355,35 @@ void QueryCPUInfo()
|
||||
}
|
||||
}
|
||||
|
||||
spdlog::info("CPU Vendor ID '{:s}'\n", pi.m_szProcessorID);
|
||||
spdlog::info("Logical processors '{:d}'\n", pi.m_nLogicalProcessors);
|
||||
spdlog::info("Physical processors '{:d}'\n", pi.m_nPhysicalProcessors);
|
||||
spdlog::info("L1 cache (KiB) '{:d}'\n", pi.m_nL1CacheSizeKb);
|
||||
spdlog::info("L1 cache (Dsc) '0x{:x}'\n", pi.m_nL1CacheDesc);
|
||||
spdlog::info("L2 cache (KiB) '{:d}'\n", pi.m_nL2CacheSizeKb);
|
||||
spdlog::info("L2 cache (Dsc) '0x{:x}'\n", pi.m_nL2CacheDesc);
|
||||
spdlog::info("L3 cache (KiB) '{:d}'\n", pi.m_nL3CacheSizeKb);
|
||||
spdlog::info("L3 cache (Dsc) '0x{:x}'\n", pi.m_nL3CacheDesc);
|
||||
spdlog::info("Clock rate (CPS) '{:d}'\n", pi.m_Speed);
|
||||
spdlog::info("CPU model identifier : '{:s}'\n", pi.m_szProcessorBrand);
|
||||
spdlog::info("CPU vendor identifier : '{:s}'\n", pi.m_szProcessorID);
|
||||
spdlog::info("CPU core count : '{:10d}' ({:s})\n", pi.m_nPhysicalProcessors, "Physical");
|
||||
spdlog::info("CPU core count : '{:10d}' ({:s})\n", pi.m_nLogicalProcessors, "Logical");
|
||||
spdlog::info("L1 cache (KiB): '{:10d}'\n", pi.m_nL1CacheSizeKb);
|
||||
spdlog::info("L1 cache (Dsc): '{:#10x}'\n" , pi.m_nL1CacheDesc);
|
||||
spdlog::info("L2 cache (KiB): '{:10d}'\n", pi.m_nL2CacheSizeKb);
|
||||
spdlog::info("L2 cache (Dsc): '{:#10x}'\n" , pi.m_nL2CacheDesc);
|
||||
spdlog::info("L3 cache (KiB): '{:10d}'\n", pi.m_nL3CacheSizeKb);
|
||||
spdlog::info("L3 cache (Dsc): '{:#10x}'\n" , pi.m_nL3CacheDesc);
|
||||
spdlog::info("Clock speed (CPS): '{:10d}'\n", pi.m_Speed);
|
||||
|
||||
MEMORYSTATUSEX statex{};
|
||||
statex.dwLength = sizeof(statex);
|
||||
|
||||
if (GlobalMemoryStatusEx(&statex))
|
||||
{
|
||||
spdlog::info("Total system memory (MiB): '{:10d}' ({:s})\n", (statex.ullTotalPhys / 1024) / 1024, "Physical");
|
||||
spdlog::info("Avail system memory (MiB): '{:10d}' ({:s})\n", (statex.ullAvailPhys / 1024) / 1024, "Physical");
|
||||
spdlog::info("Total system memory (MiB): '{:10d}' ({:s})\n", (statex.ullTotalVirtual / 1024) / 1024, "Virtual");
|
||||
spdlog::info("Avail system memory (MiB): '{:10d}' ({:s})\n", (statex.ullAvailVirtual / 1024) / 1024, "Virtual");
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::error("Unable to retrieve system memory information: {:s}\n",
|
||||
std::system_category().message(static_cast<int>(::GetLastError())));
|
||||
}
|
||||
}
|
||||
|
||||
void PrintHAddress() // Test the sigscan results
|
||||
{
|
||||
std::cout << "+----------------------------------------------------------------+" << std::endl;
|
||||
|
@ -13,5 +13,5 @@ void Systems_Shutdown();
|
||||
|
||||
void WS_Init();
|
||||
void WS_Shutdown();
|
||||
void QueryCPUInfo();
|
||||
void QuerySystemInfo();
|
||||
void PrintHAddress();
|
||||
|
@ -458,7 +458,7 @@ void CConsole::FindFromPartial(void)
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
std::sort(m_vsvSuggest.begin(), m_vsvSuggest.end(), CheckStringLexicographically);
|
||||
std::sort(m_vsvSuggest.begin(), m_vsvSuggest.end(), CompareStringLexicographically);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -20,11 +20,14 @@ string ConvertToWinPath(const string& svInput);
|
||||
string Base64Encode(const string& svInput);
|
||||
string Base64Decode(const string& svInput);
|
||||
|
||||
bool CompareStringAlphabetically(const string& svA, const string& svB);
|
||||
bool CompareStringLexicographically(const string& svA, const string& svB);
|
||||
|
||||
bool StringReplace(string& svInput, const string& svFrom, const string& svTo);
|
||||
string StringEscape(const string& svInput);
|
||||
string StringUnescape(const string& svInput);
|
||||
vector<int> StringToBytes(const string& svInput, bool bNullTerminator);
|
||||
vector<int> PatternToBytes(const string& svInput);
|
||||
bool CheckStringLexicographically(const string& svA, const string& svB);
|
||||
vector<int> IntToDigits(int value);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -332,6 +332,26 @@ string Base64Decode(const string& svInput)
|
||||
return results;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For comparing input strings alphabetically
|
||||
bool CompareStringAlphabetically(const string& svA, const string& svB)
|
||||
{
|
||||
int i = 0;
|
||||
while (svA[i] != '\0' && svA[i] == svB[i])
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
return (svA[i] - svB[i]) < 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For comparing input strings lexicographically
|
||||
bool CompareStringLexicographically(const string& svA, const string& svB)
|
||||
{
|
||||
return svA < svB;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For replacing parts of a given string.
|
||||
bool StringReplace(string& svInput, const string& svFrom, const string& svTo)
|
||||
@ -443,8 +463,14 @@ vector<int> PatternToBytes(const string& svInput)
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For comparing input strings lexicographically
|
||||
bool CheckStringLexicographically(const string& svA, const string& svB)
|
||||
// For converting a integer into digits
|
||||
vector<int> IntToDigits(int value)
|
||||
{
|
||||
return svA < svB;
|
||||
vector<int> vDigits;
|
||||
for (; value > 0; value /= 10)
|
||||
{
|
||||
vDigits.push_back(value % 10);
|
||||
}
|
||||
std::reverse(vDigits.begin(), vDigits.end());
|
||||
return vDigits;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ const char* GetProcessorVendorId(void)
|
||||
return s_CpuVendorID;
|
||||
}
|
||||
|
||||
const char* GetProcessorBrand(void)
|
||||
const char* GetProcessorBrand(bool bRemovePadding = true)
|
||||
{
|
||||
if (s_bCpuBrandInitialized)
|
||||
{
|
||||
@ -282,12 +282,12 @@ const char* GetProcessorBrand(void)
|
||||
}
|
||||
s_bCpuBrandInitialized = true;
|
||||
|
||||
memset(&s_CpuBrand, 0, sizeof(s_CpuBrand));
|
||||
memset(&s_CpuBrand, '\0', sizeof(s_CpuBrand));
|
||||
|
||||
const char* pchVendor = GetProcessorVendorId();
|
||||
if (0 == _stricmp(pchVendor, "GenuineIntel"))
|
||||
if (0 == _stricmp(pchVendor, "AuthenticAMD") || 0 == _stricmp(pchVendor, "GenuineIntel"))
|
||||
{
|
||||
// Intel brand string.
|
||||
// AMD/Intel brand string.
|
||||
if (cpuid(0x80000000).eax >= 0x80000004)
|
||||
{
|
||||
s_CpuBrand.cpuid[0] = cpuid(0x80000002);
|
||||
@ -295,6 +295,21 @@ const char* GetProcessorBrand(void)
|
||||
s_CpuBrand.cpuid[2] = cpuid(0x80000004);
|
||||
}
|
||||
}
|
||||
|
||||
if (bRemovePadding)
|
||||
{
|
||||
for (int i = 0; i < sizeof(s_CpuBrand.name) - 1; i++)
|
||||
{
|
||||
if (s_CpuBrand.name[i] == ' ')
|
||||
{
|
||||
if (s_CpuBrand.name[i + 1] == ' ')
|
||||
{
|
||||
s_CpuBrand.name[i] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s_CpuBrand.name;
|
||||
}
|
||||
|
||||
@ -429,17 +444,8 @@ const CPUInformation& GetCPUInformation(void)
|
||||
// This is contrary to MSDN documentation on GetSystemInfo().
|
||||
pi.m_nLogicalProcessors = si.dwNumberOfProcessors;
|
||||
|
||||
if (bAuthenticAMD)
|
||||
{
|
||||
// Quick fix for AMD Phenom: it reports 3 logical cores and 4 physical cores;
|
||||
// No AMD CPUs by the end of 2009 have HT, so we'll override HT detection here.
|
||||
pi.m_nPhysicalProcessors = pi.m_nLogicalProcessors;
|
||||
}
|
||||
else
|
||||
{
|
||||
CpuTopology topo;
|
||||
pi.m_nPhysicalProcessors = topo.NumberOfSystemCores();
|
||||
}
|
||||
CpuTopology topo;
|
||||
pi.m_nPhysicalProcessors = topo.NumberOfSystemCores();
|
||||
|
||||
// Make sure I always report at least one, when running WinXP with the /ONECPU switch,
|
||||
// it likes to report 0 processors for some reason.
|
||||
|
@ -14,7 +14,7 @@ bool CheckSSE42Technology(void);
|
||||
bool CheckSSE4aTechnology(void);
|
||||
|
||||
const char* GetProcessorVendorId(void);
|
||||
const char* GetProcessorBrand(void);
|
||||
const char* GetProcessorBrand(bool bRemovePadding);
|
||||
|
||||
const CPUInformation& GetCPUInformation(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user