master
ColumbusTech 2018-02-03 15:47:45 +03:00
parent b2d30834cc
commit 9e3612558f
2 changed files with 0 additions and 67 deletions

View File

@ -4,8 +4,6 @@
#include <unistd.h>
#endif
#include <cstdlib>
namespace Columbus
{

View File

@ -1,65 +0,0 @@
#ifdef __linux
#define COLUMBUS_PLATFORM_LINUX
#include <sys/sysinfo.h>
#include <unistd.h>
#endif
#include <cstdlib>
namespace Columbus
{
class Info
{
public:
static unsigned int getCPUCount();
static unsigned long getRAMSize();
static unsigned long getRAMFree();
static int getRAMUsage();
};
unsigned int Info::getCPUCount()
{
#ifdef COLUMBUS_PLATFORM_LINUX
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
}
unsigned long Info::getRAMSize()
{
#ifdef COLUMBUS_PLATFORM_LINUX
struct sysinfo info;
if (sysinfo(&info) == -1) return 0;
return info.totalram / (1024 * 1024);
#endif
}
unsigned long Info::getRAMFree()
{
#ifdef COLUMBUS_PLATFORM_LINUX
struct sysinfo info;
if (sysinfo(&info) == -1) return 0;
return info.freeram / (1024 * 1024);
#endif
}
int Info::getRAMUsage()
{
#ifdef COLUMBUS_PLATFORM_LINUX
struct sysinfo info;
if (sysinfo(&info) == -1) return 0;
float usage = static_cast<float>(getRAMFree()) / static_cast<float>(getRAMSize());
return static_cast<int>(100 - usage * 100);
#endif
}
}
#undef COLUMBUS_PLATFORM_LINUX