Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Speeding up search - Locate For or Seek?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00397065
Message ID:
00397882
Vues:
29
>Brien,
>
>I just re-tested another six time with the same results. The only modification to your code that I made was the addition of an additional FOR...NEXT and variables to hold the totals. Again, the average was SEEK was more than 250% faster than LOCATE, with the average being around 1.25 for LOCATE and .50 for SEEK. Tests were conducted using VFP 6.0 SP4 on PII 350 with 128 mb of RAM. The cursor created was on the local drive.

George,

Given your system specs, I don't know why we are experiencing such drastically different results. I am running the code in VFP 6.0 SP3 on a standalone WinBook PII 300 with 128MB of RAM. I modified the code to run 10x and these are the results:

Locate: 4.02 seconds vs. Seek: 3.90 seconds.
Locate: 3.97 seconds vs. Seek: 3.90 seconds.
Locate: 3.98 seconds vs. Seek: 3.91 seconds.
Locate: 3.97 seconds vs. Seek: 3.90 seconds.
Locate: 3.97 seconds vs. Seek: 3.97 seconds.
Locate: 4.16 seconds vs. Seek: 4.25 seconds.
Locate: 4.35 seconds vs. Seek: 4.24 seconds.
Locate: 4.32 seconds vs. Seek: 4.24 seconds.
Locate: 4.35 seconds vs. Seek: 4.11 seconds.
Locate: 3.98 seconds vs. Seek: 3.90 seconds.


Anyone else want to test the code?
LOCAL lnFile, lnI, lnJ, lnLocate, lnSeek, lnTime

IF !USED("Test")
  CREATE CURSOR Test (pID i)
  INDEX ON pID TAG pID
  FOR lnI = 1 TO 1000
    INSERT INTO Test VALUE (lnI)
  ENDFOR
ENDIF

lnFile = FCREATE("TestResults.txt")
FOR lnI = 1 TO 10
  SET ORDER TO
  lnTime = SECONDS()
  FOR lnJ = 1 TO 10000
    LOCATE FOR pID = 699
  ENDFOR
  lnLocate = SECONDS() - lnTime

  SET ORDER TO pID
  lnTime = SECONDS()
  FOR lnJ = 1 TO 10000
    SET ORDER TO pID
    SEEK(699)
    SET ORDER TO
  ENDFOR
  lnSeek = SECONDS() - lnTime
  FPUTS(lnFile,"Locate: " + ALLT(STR(ROUND(lnLocate,2),10,2)) + ;
    " seconds vs. Seek: " + ALLT(STR(ROUND(lnSeek,2),10,2)) + " seconds.")
ENDFOR
FCLOSE(lnFile)

MODI FILE TestResults.txt
Brien R. Givens

Brampwood Systems
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform