The Original (Basic Dialects)


Generic Basic/Applesoft

10 rem 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 "Accuracy ";abs (1010-s/5)
110 print "Random ";abs (1000-r)

GW-BASIC

10 rem Ahl's simple benchmark
15 time$="00:00:00"
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 "Accuracy ";abs (1010-s/5)
110 print "Random ";abs (1000-r)  
115 print "Time ";time$	

Chimpunk Basic

10 REM Ahl's simple benchmark
11 GOSUB 1100 : REM Randomize
20 FOR n = 1 TO 100 : a = n
30 FOR i = 1 TO 10
40 a = SQRT(a) : GOSUB 1000 : r = r+rnd
50 NEXT i
60 FOR i = 1 TO 10
70 a = a^2 : GOSUB 1000 : r = r+rnd
80 NEXT i
90 s = s+a : NEXT n
100 PRINT "Accuracy ";ABS(1010-s/5)
110 PRINT "Random ";ABS(1000-r)
120 END
1000 seedh = (seed/65536) AND 65535
1010 seedl = seed AND 65535
1020 seedh = (seedh*17406+seedl*3+(seedl*17406+40643)/65536+38) AND 65535
1030 seedl = (seedl*17406+40643) AND 65535
1040 seed = seed+1
1050 rnd = (1*((seedl+seedh) AND 65535))/65535
1060 RETURN
1100 PRINT"seed? "
1110 INPUT seed
1120 RETURN

Digital RSTS/E Basic-Plus

10 rem Ahl's simple benchmark
20 t1=time(1%)/10
30 while t1*10=time(1%)
40 next
41 t1=time(1%)/10.0
45 while (time(1%)/10-t1)<20
46 r=0
47 s=0
48 i1=i1+1
50 for n% = 1 to 100 : a = n%
70 for i% = 1 to 10
80 a = sqr(a) : r = r + rnd(1)
100 next i%
110 for i% = 1 to 10
120 a = a^2 : r = r + rnd(1)
140 next i%
150 s = s + a : next n%
165 next
166 print i1;" iterations."
167 t=time(1%)/10-t1
167 print t/i1;" seconds per iteration"
170 print abs (1010-s/5)
180 print abs (1000-r)
190 end


Digital VAX BASIC

10 rem Ahl's simple benchmark
20 t1=time(0)
30 while t1=time(0)
40 next
41 t1=time(0)
45 while (time(0)-t1)<20
46 r=0
47 s=0
48 iter=iter+1
50 for n% = 1 to 100
60 a = n%
70 for i% = 1 to 10
80 a = sqr(a)
90 r = r + rnd
100 next i%
110 for i% = 1 to 10
120 a = a^2
130 r = r + rnd
140 next i%
150 s = s + a
160 next n%
165 next
166 print iter;" iterations."
167 print 1.0/iter*(time(0)-t1);" seconds per iteration"
170 print "Accuracy ";abs (1010-s/5)
180 print "Random ";abs (1000-r)


Hummingbird BASIC

' Ahl's simple benchmark
' Hummingbird Basic


Sub Main
 Dim n%,i%,a,r,s,Message$, T1, T2, iters%
 T1=Timer()
 iters=0
 While ((Timer()-T1)<20)
   iters=iters+1
   s=0
   r=0
   For n = 1 To 100
     a = n
     For i = 1 To 10
       a = Sqr(a)
       r = r + Rnd()
     Next i
     For i = 1 to 10
       a = a^2 
       r = r + Rnd()
     Next i
     s = s + a 
   Next n
 Wend
 T2=Timer()
 Message="Elapsed Time: " & Format(T2-T1) & Chr$(13)
 Message=Message & "Iterations: " & Format(iters) & Chr$(13)
 Message=Message & "Seconds per iteration: " & Format((T2-T1)/iters) & Chr$(13)
 Message=Message & "Accuracy: " & Format(Abs(1010-s/5)) & Chr$(13) 
 Message=Message & "Random: " & Format(Abs(1000-r))
 Msgbox Message, 0, "Ahl's Simple Benchmark"
End Sub


Copyright © 2001,2002 Eric Korpela
korpela@ssl.berkeley.edu