Can read number of logical processors

This commit is contained in:
NissimHadar 2018-12-29 20:49:54 -08:00
parent 63ea300921
commit 3a9214747a
2 changed files with 25 additions and 8 deletions

View file

@ -7,6 +7,10 @@
//
#include "PlatformInfoScriptingInterface.h"
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
PlatformInfoScriptingInterface* PlatformInfoScriptingInterface::getInstance() {
static PlatformInfoScriptingInterface sharedInstance;
return &sharedInstance;
@ -23,6 +27,7 @@ QString PlatformInfoScriptingInterface::getOperatingSystemType() {
}
QString PlatformInfoScriptingInterface::getCPUBrand() {
#ifdef Q_OS_WIN
int CPUInfo[4] = { -1 };
unsigned nExIds, i = 0;
char CPUBrandString[0x40];
@ -42,16 +47,21 @@ QString PlatformInfoScriptingInterface::getCPUBrand() {
}
return CPUBrandString;
//////string includes manufacturer, model and clockspeed
////cout << "CPU Type: " << CPUBrandString << endl;
////SYSTEM_INFO sysInfo;
////GetSystemInfo(&sysInfo);
////cout << "Number of Cores: " << sysInfo.dwNumberOfProcessors << endl;
#else
return "NOT IMPLEMENTED";
#endif
}
////MEMORYSTATUSEX statex;
////statex.dwLength = sizeof (statex);
////GlobalMemoryStatusEx(&statex);
////cout << "Total System Memory: " << (statex.ullTotalPhys / 1024) / 1024 << "MB" << endl;
int PlatformInfoScriptingInterface::getNumCores() {
#ifdef Q_OS_WIN
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return sysInfo.dwNumberOfProcessors;
#else
return -1;
#endif
}

View file

@ -32,6 +32,13 @@ public slots:
* @returns {string} brand of CPU
*/
QString getCPUBrand();
/**jsdoc
* Returns the number of CPU cores
*function PlatformInfo.getNumCores()
* @returns {int} number of CPU cores
*/
int getNumCores();
};
#endif // hifi_PlatformInfoScriptingInterface_h