loop-STB-test1.bas 1.95 KB
Newer Older
kollo's avatar
kollo committed
1 2 3 4 5 6
' This benchmark was taken from stbasic09 (bench.LIS)
' (to compare the performance)
'
' X11-basic wins (of course...)
'
PRINT "Kilo-OPs Benchmarks ";DATE$;" - ";TIME$
kollo's avatar
kollo committed
7
DIM m(5+1)
kollo's avatar
kollo committed
8 9 10
loop%=10000

PRINT "Benchmark 1 : FOR-loop(";loop%;") "
11 12 13 14
t=TIMER
tdif=loop%
FOR i=1 TO loop%
  k%=i
kollo's avatar
kollo committed
15
NEXT i
16
timedif=TIMER-t
kollo's avatar
kollo committed
17 18 19
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 2 : REPEAT-loop(";loop%;") "
20 21
t=TIMER
k%=0
kollo's avatar
kollo committed
22
REPEAT
23 24 25
  k%=k%+1
UNTIL k%>loop%-1
timedif=TIMER-t
kollo's avatar
kollo committed
26 27 28
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 2b : REPEAT-loop(";loop%;") +INC"
29 30
t=TIMER
k%=0
kollo's avatar
kollo committed
31 32
REPEAT
  INC k%
33 34
UNTIL k%>loop%-1
timedif=TIMER-t
kollo's avatar
kollo committed
35 36 37
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 3 : DO/LOOP-loop(";loop%;") k/k*k+k-k"
38 39 40
t=TIMER
k=0
DO
kollo's avatar
kollo committed
41
  INC k
42 43
  a=k/k*k+k-k
  EXIT IF k>=loop%
kollo's avatar
kollo committed
44
LOOP
45
timedif=TIMER-t
kollo's avatar
kollo committed
46 47 48
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 4 : WHILE-loop(";loop%;") k/2*3+4-5"
49 50
t=TIMER
k=0
kollo's avatar
kollo committed
51
WHILE k < loop%
52 53
  k=k+1
  a=k/2*3+4-5
kollo's avatar
kollo committed
54
WEND
55
timedif=TIMER-t
kollo's avatar
kollo committed
56 57 58
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 5 : REPEAT-loop(";loop%;") k/2, GOSUB "
59 60
t=TIMER
k=0
kollo's avatar
kollo committed
61
REPEAT
62 63
  k=k+1
  a=k/2*3+4-5
kollo's avatar
kollo committed
64
  GOSUB dummy
65 66
UNTIL k >=loop%
timedif=TIMER-t
kollo's avatar
kollo committed
67 68 69
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 6 : REPEAT-loop(";loop%;") k/2, GOSUB, FOR-loop(5)"
70 71
t=TIMER
k=0
kollo's avatar
kollo committed
72
REPEAT
73 74
  k=k+1
  a=k/2*3+4-5
kollo's avatar
kollo committed
75
  GOSUB dummy
76
  FOR l=1 TO 5
kollo's avatar
kollo committed
77
  NEXT l
78 79
UNTIL k>=loop%
timedif=TIMER-t
kollo's avatar
kollo committed
80 81 82
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 7 : REPEAT-loop(";loop%;") k/2, GOSUB, FOR-loop(5) m(l)"
83 84
t=TIMER
k=0
kollo's avatar
kollo committed
85
REPEAT
86 87
  k=k+1
  a=k/2*3+4-5
kollo's avatar
kollo committed
88
  GOSUB dummy
89 90
  FOR l=1 TO 5
    m(l)=a
kollo's avatar
kollo committed
91
  NEXT l
92 93
UNTIL k>=loop%
timedif=TIMER-t
kollo's avatar
kollo committed
94 95 96
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)

PRINT "Benchmark 8 : REPEAT-loop(";loop%;") k^2, LOG(k), SIN(k)"
97 98
t=TIMER
k=0
kollo's avatar
kollo committed
99
REPEAT
100 101 102 103 104 105
  k=k+1
  a=k^2
  b=LOG(k)
  c=SIN(k)
UNTIL k>=loop%
timedif=TIMER-t
kollo's avatar
kollo committed
106
PRINT "Time= ";timedif;"  Kilo-OPs= ";INT(tdif/timedif)
107
QUIT
kollo's avatar
kollo committed
108
PROCEDURE dummy
109
  b=a
kollo's avatar
kollo committed
110
RETURN