diff --git a/ColumbusInfo.hpp b/ColumbusInfo.hpp index 3e3cc3e..a9e48c6 100644 --- a/ColumbusInfo.hpp +++ b/ColumbusInfo.hpp @@ -9,7 +9,10 @@ #include #endif +#include #include +#include +#include namespace Columbus { @@ -18,7 +21,7 @@ namespace Columbus { public: static unsigned int getCPUCount(); - static unsigned int getCPUSpeed(); + static unsigned int getCPUFrequency(); static unsigned long getRAMSize(); static unsigned long getRAMFree(); @@ -38,7 +41,7 @@ namespace Columbus #endif } - unsigned int Info::getCPUSpeed() + unsigned int Info::getCPUFrequency() { #ifdef COLUMBUS_PLATFORM_WINDOWS wchar_t Buffer[_MAX_PATH]; @@ -59,6 +62,19 @@ namespace Columbus RegQueryValueEx(hKey, L"~MHz", NULL, NULL, (LPBYTE)&dwMHz, &BufSize); return dwMHz; #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()