Creative Computing Benchmark Code


This is the original version from the November 1983 edition:

1 ' Ahl's simple benchmark test
2 ' In Lines 30 and 40, some computers
3 ' may require RND(1) for correct results
10 PRINT "Accuracy  Random"
20 FOR N=1 TO 100:A=N
30 FOR I=1 TO 10:A=SQR(A):R=R+RND(0):NEXT I
40 FOR I=1 TO 10:A=A^2:R=R+RND(0):NEXT I
50 S=S+A:NEXT N
60 PRINT ABS(1010-S/5);ABS(1000-R)


The following is from later 1984 version of the benchmark code, 
which reduced the number of compound statements on a line:

10 ' Ahl's Simple Benchmark
20 FOR N=1 TO 100: A=N
30 FOR I=1 TO 10
40 A=SQR(A): R=R+RND(1)
50 NEXT I
60 FOR I=1 TO 10
70 A=A^2: R=R+RND(1)
80 NEXT I
90 S=S+A: NEXT N
100 PRINT ABS(1010-S/5)
110 PRINT ABS(1000-R)