-- Time estimation -- This program can be used in order to estimate the -- time of access to Rigal data structures, as well as -- understand expensive and not expensive operations. -- Results in speed.res. -- Measurements are in cs - 1/100 of seconds. -- The computer clock gives results with resolution -- not more than 6 cs. So, normally you shouldn't pay attention -- to fluctuations less than 10 cs. -- MEASUREMENTS -- For 5000 times on LEO (IBM AT 486) computer , in 1/100 of seconds -- counter list-cr tree-cr list[19] tree.(19) -- Int/11 1600 600 4500 1000 1000 -- Int/72 350 140 1300 220 220 -- Comp/11 65 48 620 80 250 -- Comp/72 11 10 125 13 35 -- Comp/72/Win 11 15 150 16 35 -- LEGEND: -- Int - interpreter. Comp - compiled program -- 11 - non-turbo mode. 11 times faster than IBM XT 88 /4.7 MHz -- 72 - turbo mode. 72 times faster than ------- " -------- -- Win - MS-Windows version. #M -- OPEN S 'speed.res'; OPEN S ' '; $EOLD:=(.0 0 0 0 0 0 0 0.); $CORR:=0; -- All tested operations are performed in loops. These loops -- are controlled by counter. Since we are not interested in -- time consumed by counter, we have to substract the time -- consumed by the counter ($CORR) from all experiments. $MAX:=20000; -- Useful values: Maximal 20000. -- Minimal 26 #time(); $I:=1; LOOP $I+:=1; IF $I=$MAX->BREAK FI; END; $CORR:=#time(); S<< ' Correction = ' $CORR ' cs used by the counter ' ; $I:=1; LOOP $I+:=1; IF $I=$MAX->BREAK FI; $Z!.:=T; END; S<< ' Creation of list with ' $MAX ' elements ' #time() cs ; $I:=0; LOOP $I+:=1; IF $I=$MAX->BREAK FI; $TR++:=<. #CHR(#ORD(A)+ $I MOD 25) :T.>; END; S<< ' Creation of tree with ' $MAX '(different=' #LEN($TR) ') elements ' #time() cs ; -- PRINT $TR; $J:=1; LOOP $I:=1; LOOP $I+:=1; IF $I=$MAX->BREAK FI; $R:=$Z[$J]; END; S << ' Access to ' $J '-th element of list ' $MAX ' times ' #time() cs; $J:=$J+3; IF $J>=20->BREAK FI; END; $J:=0; LOOP $LET:=#CHR(#ORD(A)+ $J MOD 26); $I:=1; LOOP $I+:=1; IF $I=$MAX->BREAK FI; $R:=$TR.$LET; END; S << ' Access to ' $J '-th element (' $LET ') of tree ' $MAX ' times ' #time() cs; $J:=$J+3; IF $J>=26->BREAK FI; END; #CALL_PAS(1 'Press ENTER'); ## #time / $E:=#CALL_PAS(89); -- Current time , 8 integers -- Last 2 are seconds and centi-seconds -- S<<$E; $EOLD:=LAST #M $EOLD; $sec:=$E[7]-$EOLD[7]; -- seconds elapsed after last #time IF $sec<0 -> $sec+:=60;FI; $td:=($E[8]-$EOLD[8]) +100*$sec -LAST #M $CORR; LAST #M $EOLD:=$E; RETURN $td/ ##