SEQTEST.MOD 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. MODULE SeqTest;
  2. (* Sequential Benchmark *)
  3. IMPORT InitCompilerMods;
  4. FROM ModBase3 IMPORT DBFile,InitDBF,OpenDBF,DefaultFixUp;
  5. FROM DBIndxes IMPORT DBIndex, InitIndex, CloseIndex, FindPositionCh,
  6. NextRecord, PrevRecord,GoTop,GoBottom;
  7. FROM Timing IMPORT BeginTimer, ShowUsage;
  8. IMPORT StringIO;
  9. IMPORT StrConv;
  10. CONST
  11. KeyLen = 30;
  12. TYPE
  13. KeyStr = ARRAY [0..KeyLen-1] OF CHAR;
  14. VAR
  15. DBF : DBFile;
  16. NDX : DBIndex;
  17. DataRef : LONGINT;
  18. Found : BOOLEAN;
  19. counter :CARDINAL;
  20. string :ARRAY[0..79] OF CHAR;
  21. BEGIN
  22. BeginTimer();
  23. counter:=1;
  24. (* start timer counting *)
  25. InitDBF('Modbase.DBF',DBF,0,FALSE,TRUE,FALSE,DefaultFixUp);
  26. IF OpenDBF(DBF) THEN END;
  27. InitIndex("ModBase.NDX", NDX,DBF, 30,FALSE,TRUE,TRUE);
  28. GoTop(NDX);
  29. (* FindPositionCh(NDX, "", Found); *) (* prepare for sequential access *)
  30. WHILE NextRecord(NDX, DataRef) DO (* step forward through index *)
  31. INC(counter);
  32. END (* while *);
  33. StrConv.CardinalToStr(counter,0,string);
  34. StringIO.WriteStr(StringIO.outp,string);
  35. StringIO.WriteEol(StringIO.outp,' Keys found');
  36. counter:=1;
  37. (* should change to gotop, gobottom *)
  38. (* FindPositionCh(NDX, 377C, Found);*)
  39. GoBottom(NDX); (* prepare for sequential access *)
  40. WHILE PrevRecord(NDX, DataRef) DO (* step backward through index *)
  41. INC(counter) ;
  42. END (* while *);
  43. StrConv.CardinalToStr(counter,0,string);
  44. StringIO.WriteStr(StringIO.outp,string);
  45. StringIO.WriteEol(StringIO.outp,' Keys found');
  46. CloseIndex(NDX);
  47. ShowUsage('Seqential test'); (* display elasped time *)
  48. END SeqTest.
  49.