From cd76a7ae64b82c2001476548a8c5c70873045083 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 10 Mar 2016 10:27:14 +0100 Subject: systemunit.pas aufgerÀumt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- systemunit.pas | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/systemunit.pas b/systemunit.pas index 763c8db..d4ec24b 100644 --- a/systemunit.pas +++ b/systemunit.pas @@ -36,19 +36,16 @@ begin reset(procstat); while not eof(procstat) do begin readln(procstat,s); - if pos('cpu ',s)=1 then break; + if startetMit('cpu ',s) then break; + s:=''; end; closefile(procstat); - if pos('cpu ',s)<>1 then exit; - delete(s,1,pos(' ',s)); - s:=trim(s); + if s='' then exit; used:=0; idle:=0; for i:=0 to 3 do begin used:=used+idle; - idle:=strtoint(copy(s,1,pos(' ',s)-1)); - delete(s,1,pos(' ',s)); - s:=trim(s); + idle:=strtoint(erstesArgument(s)); end; result:=(used-_cpuLastUsed)/max(1,used-_cpuLastUsed + idle-_cpuLastIdle); _cpuLastUsed:=used; @@ -66,8 +63,8 @@ begin reset(procstat); while not eof(procstat) do begin readln(procstat,s); - if (pos('cpu',s)=1) and - (pos('cpu ',s)<>1) then + if (not startetMit('cpu ',s)) and + startetMit('cpu',s) then inc(result); end; closefile(procstat); @@ -90,8 +87,8 @@ begin reset(f); while not eof(f) do begin readln(f,s); - if (leftStr(s,4)='Rss:') and (rightStr(s,3)=' kB') then - result:=result+strtoint(trim(copy(s,5,length(s)-4-3))); + if startetMit('Rss:',s) and (endetMit('kB',s) or endetMit('KB',s)) then + result:=result+strtoint(s); end; closefile(f); end; @@ -108,10 +105,7 @@ begin reset(f); while not eof(f) do begin readln(f,s); - if (leftStr(s,10)='cache size') and (rightStr(s,3)=' kB') then begin - delete(s,1,pos(':',s)); - delete(s,length(s)-2,3); - s:=trim(s); + if startetMit('cache',s) and startetMit('size',s) and startetMit(':',s) and (endetMit('KB',s) or endetMit('kB',s)) then begin if result=0 then result:=strtoint(s) else result:=min(result,strtoint(s)); end; @@ -125,10 +119,8 @@ var begin result:=s; while pos('${',result)>0 do begin - s:=leftStr(result,pos('${',result)-1); - delete(result,1,pos('${',result)-1+length('${')); - name:=leftStr(result,pos('}',result)-1); - delete(result,1,length(name+'}')); + s:=erstesArgument(result,'${',false); + name:=erstesArgument(result,'}',false); result:=s+GetEnvironmentVariable(name)+result; end; end; -- cgit v1.2.3-70-g09d2