mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-07 15:31:18 +12:00
Renamed SystemInfoUnix to SystemInfoLinux.
This commit is contained in:
parent
3442fe634c
commit
f89de3d757
1 changed files with 0 additions and 0 deletions
|
@ -1,51 +0,0 @@
|
|||
#if BOOST_OS_LINUX
|
||||
|
||||
#include "util/SystemInfo/SystemInfo.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
uint64 QueryRamUsage()
|
||||
{
|
||||
long page_size = sysconf(_SC_PAGESIZE);
|
||||
|
||||
std::ifstream file("/proc/self/statm");
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
||||
uint64 no_pages;
|
||||
file >> no_pages;
|
||||
|
||||
return no_pages * page_size;
|
||||
}
|
||||
|
||||
void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel)
|
||||
{
|
||||
struct tms time_info;
|
||||
clock_t clock_now = times(&time_info);
|
||||
clock_t clock_user = time_info.tms_utime;
|
||||
clock_t clock_kernel = time_info.tms_stime;
|
||||
out_now = static_cast<uint64>(clock_now);
|
||||
out_user = static_cast<uint64>(clock_user);
|
||||
out_kernel = static_cast<uint64>(clock_kernel);
|
||||
}
|
||||
|
||||
void QueryCoreTimes(uint32 count, ProcessorTime out[])
|
||||
{
|
||||
std::ifstream file("/proc/stat");
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
|
||||
for (auto i = 0; i < count; ++i)
|
||||
{
|
||||
uint64 user, nice, kernel, idle;
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
||||
file >> user >> nice >> kernel >> idle;
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
|
||||
out[i].idle = idle;
|
||||
out[i].kernel = kernel;
|
||||
out[i].user = user + nice;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue