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
7//7//
8#include "PlatformInfoScriptingInterface.h"8#include "PlatformInfoScriptingInterface.h"
9 9
10# include <thread>
11
10#ifdef Q_OS_WIN12#ifdef Q_OS_WIN
11#include <Windows.h>13#include <Windows.h>
12#endif14#endif
@@ -34,6 +36,7 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { · 21 unmodified lines
34 // Get the information associated with each extended ID.36 // Get the information associated with each extended ID.
35 __cpuid(CPUInfo, 0x80000000);37 __cpuid(CPUInfo, 0x80000000);
36 nExIds = CPUInfo[0];38 nExIds = CPUInfo[0];
39
37 for (i = 0x80000000; i <= nExIds; ++i) {40 for (i = 0x80000000; i <= nExIds; ++i) {
38 __cpuid(CPUInfo, i);41 __cpuid(CPUInfo, i);
39 // Interpret CPU brand string42 // Interpret CPU brand string
@@ -51,16 +54,18 @@ QString PlatformInfoScriptingInterface::getCPUBrand() { · 11 unmodified lines
51 return "NOT IMPLEMENTED";54 return "NOT IMPLEMENTED";
52#endif55#endif
53}56}
54 ////MEMORYSTATUSEX statex;
55 ////statex.dwLength = sizeof (statex);
56 ////GlobalMemoryStatusEx(&statex);
57 ////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl;
58 57
59int PlatformInfoScriptingInterface::getNumCores() {58unsigned int PlatformInfoScriptingInterface::getNumLogicalCores() {
59
60 return std::thread::hardware_concurrency();
61}
62
63int PlatformInfoScriptingInterface::getTotalSystemMemoryMB() {
60#ifdef Q_OS_WIN64#ifdef Q_OS_WIN
61 SYSTEM_INFO sysInfo;65 MEMORYSTATUSEX statex;
62 GetSystemInfo(&sysInfo);66 statex.dwLength = sizeof (statex);
63 return sysInfo.dwNumberOfProcessors;67 GlobalMemoryStatusEx(&statex);
68 return statex.ullTotalPhys / 1024 / 1024;
64#else69#else
65 return -1;70 return -1;
66#endif71#endif