5MODE7
10REM > ClockSp
20REM Calculate CPU clock speed
30PRINT"BBC BASIC CPU Timing Program"
40T%=TIME:REPEATUNTILTIME>T%+50
50B=1:B%=1:C=1000:C%=1000:D=5100:D%=5
100:Z=0:Z%=0
60PRINT"Real REPEAT loop ";:T%=TIM
E:A=Z:REPEATA=A+B:UNTILA>C:T%=TIME-T%:PR
OCp(40800/T%)
70PRINT"Integer REPEAT loop ";:T%=TIM
E:A%=Z%:REPEATA%=A%+B%:UNTILA%>C%:T%=TIM
E-T%:PROCp(24000/T%)
80PRINT"Real FOR loop ";:T%=TIM
E:FORA=Z TO D STEPB:NEXT:T%=TIME-T%:PROC
p(51000/T%)
90PRINT"Integer FOR loop ";:T%=TIM
E:FORA%=Z% TO D% STEPB%:NEXT:T%=TIME-T%:
PROCp(17800/T%)
100PRINT"Floating-Point Test ";
110A=1:T%=TIME:FORJ%=1 TO 29:A=TAN(ATN
(EXP(LN(SQR(A*A)))))+1:NEXT:T%=TIME-T%:P
ROCp(66500/T%)
120PRINT"Ackermann Recursion ";
130M%=3:T%=TIME:FORN%=1 TO 3:Z%=FNAck(
M%,N%):NEXT:T%=TIME-T%:PROCp(254500/T%)
140PRINT"Combined Average ";:PROCp(
FNspeed)
150PRINT'"Compared to a BBC B running
at 2.00MHz"
160END
170:
180DEFFNAck(M%,N%)
190IF M%=0:=N%+1
200IF N%=0:=FNAck(M%-1,1)
210=FNAck(M%-1,FNAck(M%,N%-1))
220DEFPROCp(T%):PRINT"Speed: ";T%DIV10
0;".";RIGHT$("0"+STR$(T%),2);"MHz":ENDPR
OC
230:
240 This is calibrated against a
250 BBC model B with no second
260 processor, running BASIC II
270 and with almost all interupts
280 turned off using:
290 ?&FE4E=&3F
300 This gives 2.00MHz.
310:
320 Savage Floating Point test and
330 Ackermann Recursion test added
340 -Mar-93, based on A&B Jan 90.
350:
360DEFFNspeed:LOCAL A,B,C,D,Z,A%,B%,C%
,D%,U%,V%,W%,X%,Y%,Z%
370T%=TIME:REPEATUNTILTIME>T%+50
380B=1:B%=1:C=1000:C%=1000:D=5100:D%=5
100:Z=0:Z%=0
390T%=TIME:A=Z:REPEATA=A+B:UNTILA>C:T%
=TIME-T%:U%=(40800/T%)
400T%=TIME:A%=Z%:REPEATA%=A%+B%:UNTILA
%>C%:T%=TIME-T%:V%=(24000/T%)
410T%=TIME:FORA=Z TO D STEPB:NEXT:T%=T
IME-T%:W%=(51000/T%)
420T%=TIME:FORA%=Z% TO D% STEPB%:NEXT:
T%=TIME-T%:X%=(17800/T%)
430A=1:T%=TIME:FORJ%=1 TO 29:A=TAN(ATN
(EXP(LN(SQR(A*A)))))+1:NEXT:T%=TIME-T%:Y
%=(66500/T%)
440=(U%+V%+W%+X%+Y%)DIV5
450REM Returns CPU speed*100