Added process cpu use and per-core global cpu use to linux overlay.

This commit is contained in:
Tom Lally 2022-09-01 16:45:52 +01:00
parent 5f484b22d2
commit 2d30edcbc6
5 changed files with 181 additions and 79 deletions

View file

@ -0,0 +1,29 @@
#include "util/ProcessorTime/ProcessorTime.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;
}