master
ColumbusTech 2018-02-06 16:41:30 +03:00
parent ef9dc92d4d
commit 2aa6f13458
1 changed files with 18 additions and 2 deletions

View File

@ -9,7 +9,10 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <cstdlib>
#include <cstdio> #include <cstdio>
#include <fstream>
#include <string>
namespace Columbus namespace Columbus
{ {
@ -18,7 +21,7 @@ namespace Columbus
{ {
public: public:
static unsigned int getCPUCount(); static unsigned int getCPUCount();
static unsigned int getCPUSpeed(); static unsigned int getCPUFrequency();
static unsigned long getRAMSize(); static unsigned long getRAMSize();
static unsigned long getRAMFree(); static unsigned long getRAMFree();
@ -38,7 +41,7 @@ namespace Columbus
#endif #endif
} }
unsigned int Info::getCPUSpeed() unsigned int Info::getCPUFrequency()
{ {
#ifdef COLUMBUS_PLATFORM_WINDOWS #ifdef COLUMBUS_PLATFORM_WINDOWS
wchar_t Buffer[_MAX_PATH]; wchar_t Buffer[_MAX_PATH];
@ -59,6 +62,19 @@ namespace Columbus
RegQueryValueEx(hKey, L"~MHz", NULL, NULL, (LPBYTE)&dwMHz, &BufSize); RegQueryValueEx(hKey, L"~MHz", NULL, NULL, (LPBYTE)&dwMHz, &BufSize);
return dwMHz; return dwMHz;
#endif #endif
#ifdef COLUMBUS_PLATFORM_LINUX
std::ifstream f("/proc/cpuinfo");
if (!f.is_open()) return 0;
std::string line;
while (getline(f, line))
{
if (line.substr(0, 7) == "cpu MHz")
return atoi(line.substr(line.find(":") + 1).c_str());
}
#endif
} }
unsigned long Info::getRAMSize() unsigned long Info::getRAMSize()