mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 05:51:19 +12:00
Use Cemu basic types.
This commit is contained in:
parent
8a8d9a2f73
commit
60cb1aebd8
4 changed files with 23 additions and 23 deletions
|
@ -1,11 +1,11 @@
|
||||||
#include "util/SystemInfo/SystemInfo.h"
|
#include "util/SystemInfo/SystemInfo.h"
|
||||||
|
|
||||||
uint64_t ProcessorTime::work()
|
uint64 ProcessorTime::work()
|
||||||
{
|
{
|
||||||
return user + kernel;
|
return user + kernel;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ProcessorTime::total()
|
uint64 ProcessorTime::total()
|
||||||
{
|
{
|
||||||
return idle + user + kernel;
|
return idle + user + kernel;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ double ProcessorTime::Compare(ProcessorTime &last, ProcessorTime &now)
|
||||||
|
|
||||||
void QueryProcTime(ProcessorTime &out)
|
void QueryProcTime(ProcessorTime &out)
|
||||||
{
|
{
|
||||||
uint64_t now, user, kernel;
|
uint64 now, user, kernel;
|
||||||
QueryProcTime(now, user, kernel);
|
QueryProcTime(now, user, kernel);
|
||||||
|
|
||||||
out.idle = now - (user + kernel);
|
out.idle = now - (user + kernel);
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
struct ProcessorTime
|
struct ProcessorTime
|
||||||
{
|
{
|
||||||
uint64_t idle{}, kernel{}, user{};
|
uint64 idle{}, kernel{}, user{};
|
||||||
|
|
||||||
uint64_t work();
|
uint64 work();
|
||||||
uint64_t total();
|
uint64 total();
|
||||||
|
|
||||||
static double Compare(ProcessorTime &last, ProcessorTime &now);
|
static double Compare(ProcessorTime &last, ProcessorTime &now);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t GetProcessorCount();
|
uint32 GetProcessorCount();
|
||||||
uint64_t QueryRamUsage();
|
uint64 QueryRamUsage();
|
||||||
void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel);
|
void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel);
|
||||||
void QueryProcTime(ProcessorTime &out);
|
void QueryProcTime(ProcessorTime &out);
|
||||||
void QueryCoreTimes(uint32_t count, ProcessorTime out[]);
|
void QueryCoreTimes(uint32 count, ProcessorTime out[]);
|
|
@ -7,42 +7,42 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
uint32_t GetProcessorCount()
|
uint32 GetProcessorCount()
|
||||||
{
|
{
|
||||||
return std::thread::hardware_concurrency();
|
return std::thread::hardware_concurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t QueryRamUsage()
|
uint64 QueryRamUsage()
|
||||||
{
|
{
|
||||||
long page_size = sysconf(_SC_PAGESIZE);
|
long page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
|
||||||
std::ifstream file("/proc/self/statm");
|
std::ifstream file("/proc/self/statm");
|
||||||
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
||||||
uint64_t no_pages;
|
uint64 no_pages;
|
||||||
file >> no_pages;
|
file >> no_pages;
|
||||||
|
|
||||||
return no_pages * page_size;
|
return no_pages * page_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel)
|
void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel)
|
||||||
{
|
{
|
||||||
struct tms time_info;
|
struct tms time_info;
|
||||||
clock_t clock_now = times(&time_info);
|
clock_t clock_now = times(&time_info);
|
||||||
clock_t clock_user = time_info.tms_utime;
|
clock_t clock_user = time_info.tms_utime;
|
||||||
clock_t clock_kernel = time_info.tms_stime;
|
clock_t clock_kernel = time_info.tms_stime;
|
||||||
out_now = static_cast<uint64_t>(clock_now);
|
out_now = static_cast<uint64>(clock_now);
|
||||||
out_user = static_cast<uint64_t>(clock_user);
|
out_user = static_cast<uint64>(clock_user);
|
||||||
out_kernel = static_cast<uint64_t>(clock_kernel);
|
out_kernel = static_cast<uint64>(clock_kernel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryCoreTimes(uint32_t count, ProcessorTime out[])
|
void QueryCoreTimes(uint32 count, ProcessorTime out[])
|
||||||
{
|
{
|
||||||
std::ifstream file("/proc/stat");
|
std::ifstream file("/proc/stat");
|
||||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||||
|
|
||||||
for (auto i = 0; i < count; ++i)
|
for (auto i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
uint64_t user, nice, kernel, idle;
|
uint64 user, nice, kernel, idle;
|
||||||
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
file.ignore(std::numeric_limits<std::streamsize>::max(), ' ');
|
||||||
file >> user >> nice >> kernel >> idle;
|
file >> user >> nice >> kernel >> idle;
|
||||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
#include <winternl.h>
|
#include <winternl.h>
|
||||||
#pragma comment(lib, "ntdll.lib")
|
#pragma comment(lib, "ntdll.lib")
|
||||||
|
|
||||||
uint32_t GetProcessorCount()
|
uint32 GetProcessorCount()
|
||||||
{
|
{
|
||||||
SYSTEM_INFO sys_info;
|
SYSTEM_INFO sys_info;
|
||||||
GetSystemInfo(&sys_info);
|
GetSystemInfo(&sys_info);
|
||||||
return sys_info.dwNumberOfProcessors;
|
return sys_info.dwNumberOfProcessors;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t QueryRamUsage()
|
uint64 QueryRamUsage()
|
||||||
{
|
{
|
||||||
PROCESS_MEMORY_COUNTERS pmc{};
|
PROCESS_MEMORY_COUNTERS pmc{};
|
||||||
pmc.cb = sizeof(pmc);
|
pmc.cb = sizeof(pmc);
|
||||||
|
@ -21,7 +21,7 @@ uint64_t QueryRamUsage()
|
||||||
return pmc.WorkingSetSize;
|
return pmc.WorkingSetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel)
|
void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel)
|
||||||
{
|
{
|
||||||
FILETIME ftime, fkernel, fuser;
|
FILETIME ftime, fkernel, fuser;
|
||||||
LARGE_INTEGER now, kernel, user;
|
LARGE_INTEGER now, kernel, user;
|
||||||
|
@ -41,7 +41,7 @@ void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel)
|
||||||
out_kernel = kernel.QuadPart;
|
out_kernel = kernel.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryCoreTimes(uint32_t count, ProcessorTime out[])
|
void QueryCoreTimes(uint32 count, ProcessorTime out[])
|
||||||
{
|
{
|
||||||
std::vector<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION> sppi(count);
|
std::vector<SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION> sppi(count);
|
||||||
if (NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi.data(), sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * count, nullptr)))
|
if (NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi.data(), sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * count, nullptr)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue