Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way to check memo field for a string
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01410639
Message ID:
01410678
Vues:
36
>>>>>I just tested this a few times and switched the order around. It appears you are correct. While the time changes depending on whether it is first, 2nd, 3rd, etc in the order (OCCURS() versus $ etc), $ does seem to be consistently the fastest.
>>>>
>>>>In Boris tests OCCURS() was the winner over $.
>>>
>>>:-)
>>>No way!
>>>
>>>? [$], SECONDS()-m1                   && 0.045
>>>? [OCCURS], SECONDS()-m1       && 0.284
>>>
>>>
>>>I even did this:
>>>
>>>CLEAR
>>>CREATE CURSOR crsTest (MyMemo M)
>>>APPEND BLANK
>>>REPLACE MyMemo WITH REPLICATE([A],16000000)+[ My String]
>>>DIMENSION atests[5]
>>>atests[1] = [aaa = AT("My String", MyMemo)]
>>>atests[2] = [aaa = RAT("My String", MyMemo)]
>>>atests[3] = [aaa = "My String" $ MyMemo]
>>>atests[4] = [aaa = OCCURS("My String", MyMemo)]
>>>atests[5] = [SELECT * FROM crsTest WHERE MyMemo LIKE "%My String%" INTO CURSOR aaa]
>>>RAND(-1)
>>>CREATE CURSOR Passed (Num I)
>>>INDEX ON Num TAG Passed
>>>SELECT crsTest
>>>DO WHILE .t.
>>>   lnRandom = INT(RAND()*10000000 % 5 + 1)
>>>   IF NOT SEEK(lnRandom,[Passed])
>>>      DoTest(lnRandom)
>>>      INSERT INTO Passed VALUES (lnRandom)
>>>      IF RECCOUNT([Passed]) > 4
>>>         EXIT
>>>      ENDIF
>>>   ENDIF
>>>ENDDO
>>>
>>>FUNCTION DoTest(lnNumber)
>>>    lcTest = atests[lnNumber]
>>>    m1  = SECONDS()
>>>    &lcTest
>>>    ? lcTest, SECONDS()-m1
>>>RETURN
>>>
>>>When I start it several times the [$] almost always has the same value 0.045-0.046, the rest vary from 0.045 to 0.980.
>>
>>For this particular test in my system RAT is winning.
>
>RAT because string searched is at the end :-)
>Try:
>
>CLEAR
>CREATE CURSOR crsTest (MyMemo M)
>APPEND BLANK
>REPLACE MyMemo WITH REPLICATE([A],8000000)+[ My String]+REPLICATE([A],8000000)
>DIMENSION atests[5]
>atests[1] = [aaa = AT("My String", MyMemo)]
>atests[2] = [aaa = RAT("My String", MyMemo)]
>atests[3] = [aaa = "My String" $ MyMemo]
>atests[4] = [aaa = OCCURS("My String", MyMemo)]
>atests[5] = [SELECT * FROM crsTest WHERE MyMemo LIKE "%My String%" INTO CURSOR aaa]
>RAND(-1)
>FOR lnFOr = 1 TO 10
>    CREATE CURSOR Passed (Num I)
>    INDEX ON Num TAG Passed
>    SELECT crsTest
>    DO WHILE .t.
>       lnRandom = INT(RAND()*10000000 % 5 + 1)
>       IF NOT SEEK(lnRandom,[Passed])
>          DoTest(lnRandom)
>          INSERT INTO Passed VALUES (lnRandom)
>          IF RECCOUNT([Passed]) > 4
>             EXIT
>          ENDIF
>       ENDIF
>    ENDDO
>    ?
>NEXT
>
>FUNCTION DoTest(lnNumber)
>    lcTest = atests[lnNumber]
>    m1  = SECONDS()
>    &lcTest
>    ? lcTest, SECONDS()-m1
>RETURN
>
>
>And you will see that things are changed :-)

AT() and $ were very close now, both about 0.012 / 0.013
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform