home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 2.6 KB | 102 lines | [TEXT/MPS ] |
- { statistics.impl.p © Copyright G. Sawitzki, 1988-1991}
-
-
- procedure sResume;
- {reset time to resume sNoteResult after a user-controlled delay}
- begin
- sLastTicks:=tickCount;
- end;
-
- {********* trying to clean up -- center statistics here. tag char is "s" *******}
- { For evaluation of mean and sum of deviation squares
- this procedure executes one single iteration
- obeying a provisional mean algorithm.
- At "w" the actual value is expected,
- at "stat" mean,SSQ and number of the preceding ones
- according the statlab-convention.}
-
- var DefineStat,CoreStat,UpdateStat:tStatType;
- TotalTurnAroundStat:tStatType; {gross job turn around time}
- LocalTurnAroundStat:tStatType; {local job turn around time}
- procedure initAllStats;
- begin
- initStat(DefineStat,'define');
- initStat(CoreStat,'core');
- initStat(UpdateStat,'update');
- initStat(TotalTurnAroundStat,'total job');
- initStat(LocalTurnAroundStat,'local job');
- sResume;
- end;
-
- procedure WriteStat(Stat:tStatType);
- const sep=chr(9);
- var varianz:extended;
- begin
- if gProtocolOn then with stat do
- begin
- Write(OutFile,count:6,sep,mean:8:3,sep,ssq:8:3);
- if count>1 then begin
- varianz:=ssq/(count-1);
- writeln(OutFile,sep,sqrt(varianz):8:3,sep,sqrt(varianz/count):8:3);
- end else writeln(OutFile);
- end;
- end;
-
-
- {initialize all statistics}
- procedure sInit;
- begin
- sLastTicks:=tickCount;
- sMeanTicks:=100; {a random number to start off- we are using provisional means}
- initAllStats;
- end;
-
-
- {update all statistics to account for a new result}
- procedure sNoteResult(isLocal:boolean);
- var tempticks,deltaticks:longint;
- s:str255;x:integer;
- begin
- tempticks:=sLastTicks;
- sLastTicks:=tickCount;
- deltaticks:=sLastTicks-tempticks;
- {sMeanTicks:=(19*sMeanTicks+(deltaticks))*0.05;}{moving average over 20}
- sMeanTicks:=(9*sMeanTicks+(deltaticks))*0.1; {moving average over 10}
- numtostring(deltaticks,s);
- logstring(concat ('ticksPTask Δ',chr(9),s));
- NrResults:=NrResults+1;
-
-
- AddStat(deltaTicks,TotalTurnAroundStat);
- sResume;
- end;
-
-
- { saves time and number of iterations}
- PROCEDURE ResetMeasurement;
- VAR
- myTime: longint;
- q: extended;
- s: Str255;
- BEGIN
- {save old results}
- if gProtocolOn then begin
- Repeat Until ReadDateTime(myTime)=NoErr;
- q:=(myTime-goldTime);
- NumToString(round(q),s);
- numtostring(gnrResults,gsOldResults);
- gsOldResults2:=concat(s,' ',gsOldResults);
- gsOldResults:=concat('Zeit: ',s,' s #:',gsOldResults);
- writeln(OutFile,gsoldResults2);
-
- {set new values}
-
- gnrResults:=0;
- nrResults:=0;
- repeat until ReadDateTime(oldTime)=noErr;
- repeat repeat until ReadDateTime(goldTime)=noErr; until goldTime>oldTime;
- oldTime:=goldtime;
- end;
- end;
- {*************** end clean up of statistics *****************************}
-