You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionTProcessInfo.PerSystem(out Idle, Kernel, User: single): boolean;
var
P: PUtf8Char;
U, K, I, S: cardinal;
U2, K2, I2, S2: cardinal;
begin// see http://www.linuxhowtos.org/System/procstat.htm
result := false;
P := pointer(StringFromFile('/proc/stat', {nosize=}true));
if P = nilthen
exit;
// e.g. 'cpu 3418147 18140 265232 6783435 12184 0 34219 0 0 0'
U := GetNextCardinal(P){=user} + GetNextCardinal(P){=nice};
K := GetNextCardinal(P){=system};
I := GetNextCardinal(P){=idle};
S := U + K + I;
result := S <> 0;
ifnot result then
exit;
sleep(200);
P := pointer(StringFromFile('/proc/stat', {nosize=}true));
U2 := GetNextCardinal(P){=user} + GetNextCardinal(P){=nice};
K2 := GetNextCardinal(P){=system};
I2 := GetNextCardinal(P){=idle};
S2 := U2 + K2 + I2;
Kernel := {%H-}SimpleRoundTo2Digits(((K2-K) * 100) / (S2-S));
User := {%H-}SimpleRoundTo2Digits(((U2-U) * 100) / (S2-S));
Idle := 100 - Kernel - User; // ensure sum is always 100%end; { TODO : use a diff approach for TProcessInfo.PerSystem on Linux? }
The text was updated successfully, but these errors were encountered:
Here is my edition:
The text was updated successfully, but these errors were encountered: