History

Added method to get total system memory in MB.

NissimHadar committed 7 years ago

Commit 6debd991 parent 3a921472 files · +24 −12Browse files

Showing the changes to interface/src/scripting/PlatformInfoScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

interface/src/scripting/PlatformInfoScriptingInterface.cpp+13−8
@@ -7,6 +7,8 @@ · 6 unmodified lines
77 //
88 #include "PlatformInfoScriptingInterface.h"
99
10+# include <thread>
11+
1012 #ifdef Q_OS_WIN
1113 #include <Windows.h>
1214 #endif
@@ -34,6 +36,7 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { · 21 unmodified lines
3436 // Get the information associated with each extended ID.
3537 __cpuid(CPUInfo, 0x80000000);
3638 nExIds = CPUInfo[0];
39+
3740 for (i = 0x80000000; i <= nExIds; ++i) {
3841 __cpuid(CPUInfo, i);
3942 // Interpret CPU brand string
@@ -51,16 +54,18 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { · 11 unmodified lines
5154 return "NOT IMPLEMENTED";
5255 #endif
5356 }
54− ////MEMORYSTATUSEX statex;
55− ////statex.dwLength = sizeof (statex);
56− ////GlobalMemoryStatusEx(&statex);
57− ////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl;
5857
59−int PlatformInfoScriptingInterface::getNumCores() {
58+unsigned int PlatformInfoScriptingInterface::getNumLogicalCores() {
59+
60+ return std::thread::hardware_concurrency();
61+}
62+
63+int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() {
6064 #ifdef Q_OS_WIN
61− SYSTEM_INFO sysInfo;
62− GetSystemInfo(&sysInfo);
63− return sysInfo.dwNumberOfProcessors;
65+ MEMORYSTATUSEX statex;
66+ statex.dwLength = sizeof (statex);
67+ GlobalMemoryStatusEx(&statex);
68+ return statex.ullTotalPhys / 1024 / 1024;
6469 #else
6570 return -1;
6671 #endif