CPU info upgrated
parent
f11abcafcd
commit
06f66c031d
38
Info.hpp
38
Info.hpp
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#ifdef __linux__
|
||||
#include <sys/sysinfo.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -40,20 +41,7 @@ namespace Columbus
|
|||
int GetCPUCount()
|
||||
{
|
||||
#ifdef __linux__
|
||||
int counter = 0;
|
||||
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;
|
||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#endif
|
||||
|
||||
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
||||
|
|
@ -68,27 +56,13 @@ namespace Columbus
|
|||
int GetCPUCacheSize()
|
||||
{
|
||||
#ifdef __linux__
|
||||
std::ifstream cpuinfo("/proc/cpuinfo");
|
||||
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;
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
#endif
|
||||
|
||||
#ifdef COLUMBUS_PLATFORM_WINDOWS
|
||||
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwPageSize;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue