CPU info upgrated
parent
f11abcafcd
commit
06f66c031d
38
Info.hpp
38
Info.hpp
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -40,20 +41,7 @@ namespace Columbus
|
||||||
int GetCPUCount()
|
int GetCPUCount()
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
int counter = 0;
|
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
std::ifstream cpuinfo("/proc/cpuinfo");
|
|
||||||
if (cpuinfo.is_open() == false) return 0;
|
|
||||||
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
while(getline(cpuinfo, line))
|
|
||||||
{
|
|
||||||
if (line.find("processor") != std::string::npos)
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpuinfo.close();
|
|
||||||
return counter;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
||||||
|
|
@ -68,27 +56,13 @@ namespace Columbus
|
||||||
int GetCPUCacheSize()
|
int GetCPUCacheSize()
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
std::ifstream cpuinfo("/proc/cpuinfo");
|
return sysconf(_SC_PAGESIZE);
|
||||||
if (cpuinfo.is_open() == false) return 0;
|
|
||||||
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
while(getline(cpuinfo, line))
|
|
||||||
{
|
|
||||||
if (line.find("cache size") != std::string::npos)
|
|
||||||
{
|
|
||||||
size_t sz = line.find(":") + 1;
|
|
||||||
size_t kb = line.find("KB");
|
|
||||||
return std::atoi(line.substr(sz, kb - sz).c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cpuinfo.close();
|
|
||||||
return 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
||||||
|
SYSTEM_INFO sysinfo;
|
||||||
|
GetSystemInfo(&sysinfo);
|
||||||
|
return sysinfo.dwPageSize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue