ADDTESTF.LST 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. Listing:
  2. 1 MODULE AddTestF; (* Add Benchmark *)
  3. 2 IMPORT InitCompilerMods;
  4. 3
  5. 4 FROM ModBase3 IMPORT DBFile, CloseDBF, DBFieldDescriptor,
  6. 5 BuildDBF,Record,DefaultFixUp,AppendBlank, WriteDBRec,InitDBF;
  7. 6 FROM DBIndxes IMPORT DBIndex, BuildIndex, InitIndex, CloseIndex,
  8. 7 AddRecord, FindPositionCh,SetSafetyOff,
  9. 8 AddToUpdateList,SetIndexBuffers,InsertEntry;
  10. 9 FROM DBFields IMPORT Replace;
  11. 10 FROM Timing IMPORT BeginTimer, ShowUsage;
  12. 11
  13. 12
  14. 13 FROM InOut IMPORT WriteCard;
  15. 14 (* FROM Random IMPORT RandomInit, RandomCard;*)
  16. 15 FROM Lib IMPORT RANDOM;
  17. 16
  18. 17
  19. 18
  20. 19 PROCEDURE RandStr(VAR S : ARRAY OF CHAR);
  21. ***** ^ not supported yet
  22. 20 (* Generate a string of random letters with a random length *)
  23. 21 VAR
  24. 22 I : CARDINAL;
  25. 23 Len : CARDINAL;
  26. 24 BEGIN
  27. 25 Len := 1 + (*RandomCard*)RANDOM(HIGH(S)+1) ; (* random 1 to 30 Len *)
  28. ***** ^ not supported yet
  29. ***** ^ undeclared identifier
  30. ***** ^ not supported yet
  31. ***** ^ not supported yet
  32. 26 FOR I := 0 TO Len - 1 DO
  33. 27 S[I] := CHR((*RandomCard*)RANDOM(26)+65); (* random letters *)
  34. ***** ^ not supported yet
  35. ***** ^ not supported yet
  36. ***** ^ undeclared identifier
  37. ***** ^ not supported yet
  38. ***** ^ not supported yet
  39. ***** ^ not supported yet
  40. 28 END (* for *);
  41. 29 FOR I := Len TO HIGH(S) DO (* ModBase requires space padded keys *)
  42. ***** ^ undeclared identifier
  43. ***** ^ not supported yet
  44. 30 S[I] := ' '; (* instead of a 0C terminated string *)
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. 31 END (* if *);
  48. 32 END RandStr;
  49. ***** ^ not supported yet
  50. 33 (* was keylen=30 buffers 400 *)
  51. 34 CONST
  52. 35 KeyLen = 30;
  53. 36 Buffers = 400;
  54. 37 TYPE
  55. 38 KeyStr = ARRAY [0..KeyLen-1] OF CHAR;
  56. ***** ^ not supported yet
  57. ***** ^ not supported yet
  58. 39
  59. 40 VAR
  60. 41 DBF : DBFile;
  61. 42 Fields : ARRAY [1..2] OF DBFieldDescriptor;
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. 43 NDX : DBIndex;
  65. 44 I : CARDINAL;
  66. 45 Name : KeyStr;
  67. ***** ^ not supported yet
  68. 46 Found : BOOLEAN;
  69. 47
  70. 48 BEGIN
  71. 49 BeginTimer(); (* start timer counting *)
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. 50 (* RandomInit(1);*)
  75. 51 WITH Fields[1] DO
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. 52 name := "NAME";
  79. ***** ^ undeclared identifier
  80. ***** ^ not supported yet
  81. 53 size := 30;
  82. ***** ^ undeclared identifier
  83. 54 fldtype := 'C';
  84. ***** ^ undeclared identifier
  85. 55 END (* with *);
  86. ***** ^ not supported yet
  87. 56 WITH Fields[2] DO
  88. ***** ^ not supported yet
  89. ***** ^ not supported yet
  90. 57 name := "PHONE";
  91. ***** ^ undeclared identifier
  92. ***** ^ not supported yet
  93. 58 size := 13;
  94. ***** ^ undeclared identifier
  95. 59 fldtype := 'C';
  96. ***** ^ undeclared identifier
  97. 60 END (* with *);
  98. ***** ^ not supported yet
  99. 61 InitDBF('ModBase.DBF', DBF,40000,FALSE,TRUE,FALSE,DefaultFixUp);
  100. ***** ^ not supported yet
  101. ***** ^ not supported yet
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. 62 InitIndex('ModBase.NDX',NDX,DBF,Buffers,FALSE,TRUE);
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. ***** ^ not supported yet
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. 63 IF BuildDBF( Fields,2, DBF)=0 THEN END; (* Create empty DBF file *)
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. ***** ^ not supported yet
  114. 64 IF BuildIndex(NDX, 'NAME')=0 THEN END ; (* create initial empty index *)
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. 65 (* AddToUpdateList(DBF,NDX);*)
  119. 66 FOR I := 1 TO 5000 DO
  120. 67 WriteCard(I, 8);
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. 68 REPEAT (* generate random keys *)
  124. 69 RandStr(Name);
  125. ***** ^ not supported yet
  126. ***** ^ not supported yet
  127. 70 FindPositionCh(NDX, Name, Found);
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. 71 UNTIL NOT Found; (* until not already added *)
  133. 72 AppendBlank(DBF);
  134. ***** ^ not supported yet
  135. ***** ^ not supported yet
  136. 73 Replace(DBF, 1, Name); (* store key in record *)
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. ***** ^ not supported yet
  140. 74 WriteDBRec(DBF);
  141. ***** ^ not supported yet
  142. ***** ^ not supported yet
  143. 75 InsertEntry(NDX,Name,Record(DBF));
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. ***** ^ not supported yet
  149. 76 (* add record to data file *)
  150. 77 (* AddRecord(DBF, NDX); *)
  151. 78 (* (* all ok now but good for diag*)
  152. 79 FindPositionCh(NDX, Name, Found);
  153. 80 IF NOT Found THEN
  154. 81 HALT;
  155. 82 END (* if *);
  156. 83 *)
  157. 84 END (* for *);
  158. 85 CloseIndex(NDX);
  159. ***** ^ not supported yet
  160. ***** ^ not supported yet
  161. 86 CloseDBF(DBF);
  162. ***** ^ not supported yet
  163. ***** ^ not supported yet
  164. 87 ShowUsage('add test'); (* display elaped time in seconds *)
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. 88 END AddTestF.
  168. 89
  169. 78 errors