Smartzkid
2007-09-01 17:34:58
This is an idea I came up with for one of my SMART scripts to reduce lag, and it worked well enough that I put it into a script that I plan to release soon. I told Boreas about it, and he told me to post it here, so it is.
procedure Randoms;
//variables (all integers):
//RandomProcTime: the time it takes for the procedure to finish
//[external]
//RandomCheckTime: the time since the procedure was last called
//RandomBenchTime: the average time taken to finish the procedure
var
RandomProcTime: integer;
begin
if(TimeFromMark(RandomCheckTime) < Round(RandomBenchTime * 1.1))then
Exit;
MarkTime(RandomProcTime);
MarkTime(RandomCheckTime);
FindNormalRandoms;
RandomBenchTime := ((RandomBenchTime * 7) + TimeFromMark(RandomProcTime)) / 8; //Calculate the new average time
SaveSetting('PowerKut', 'AntiLag', IntToStr(RandomBenchTime)); //So it can be retrieved at the next run
AddToReport(IntToStr(RandomBenchTime)); //Debug
end;