// CDX Read Benchmark — opens Harbour-created CDX, tests seek/scan/scope PROCEDURE Main() LOCAL i, nStart, nEnd, nCount // Open Harbour-created files USE "cdx_bench" NEW SET INDEX TO "cdx_bench.cdx" ? "TAGS=" + LTrim(Str(OrdCount())) // SEEK 50K by NAME SET ORDER TO 3 nStart := Seconds() nCount := 0 FOR i := 1 TO 50000 SEEK PadR("Name_" + PadL(LTrim(Str(i)), 5, "0"), 20) IF Found() nCount++ ENDIF NEXT nEnd := Seconds() ? "SEEK_NAME=" + LTrim(Str(Int((nEnd-nStart)*1000))) + "ms f=" + LTrim(Str(nCount)) // SCAN 50K SET ORDER TO 3 GO TOP nStart := Seconds() nCount := 0 DO WHILE !EOF() nCount++ SKIP ENDDO nEnd := Seconds() ? "SCAN=" + LTrim(Str(Int((nEnd-nStart)*1000))) + "ms c=" + LTrim(Str(nCount)) // ORDSCOPE on CITY SET ORDER TO 1 OrdScope(0, PadR("London", 15)) OrdScope(1, PadR("Seoul", 15)) nStart := Seconds() GO TOP nCount := 0 DO WHILE !EOF() nCount++ SKIP ENDDO nEnd := Seconds() ? "SCOPE=" + LTrim(Str(Int((nEnd-nStart)*1000))) + "ms c=" + LTrim(Str(nCount)) OrdScope(0, NIL) OrdScope(1, NIL) // SEEK by ID SET ORDER TO 2 nStart := Seconds() nCount := 0 FOR i := 1 TO 50000 SEEK Str(i, 8) IF Found() nCount++ ENDIF NEXT nEnd := Seconds() ? "SEEK_ID=" + LTrim(Str(Int((nEnd-nStart)*1000))) + "ms f=" + LTrim(Str(nCount)) CLOSE ALL RETURN