Refactor ProcessorTime to SystemInfo

This commit is contained in:
Tom Lally 2022-09-01 17:12:13 +01:00
parent 002acbd7a0
commit 4aaefeaefd
5 changed files with 5 additions and 5 deletions

View file

@ -0,0 +1,29 @@
#include "util/SystemInfo/SystemInfo.h"
uint64_t ProcessorTime::work()
{
return user + kernel;
}
uint64_t ProcessorTime::total()
{
return idle + user + kernel;
}
double ProcessorTime::Compare(ProcessorTime &last, ProcessorTime &now)
{
auto dwork = now.work() - last.work();
auto dtotal = now.total() - last.total();
return (double)dwork / dtotal;
}
void QueryProcTime(ProcessorTime &out)
{
uint64_t now, user, kernel;
QueryProcTime(now, user, kernel);
out.idle = now - (user + kernel);
out.kernel = kernel;
out.user = user;
}