Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way to check memo field for a string
Message
De
08/07/2009 09:24:12
 
 
À
08/07/2009 05:34:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
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:
01410862
Vues:
54
>>>>Assuming a memo field in a cursor is HUGE, and I want to look for a string: 'my string' what would be the fastest and least memory hog way of doing that? I think for sure that $ is not it... is alines() better? It won't be an exact match, in other words, I need to see if 'my string' is in there, but it may be in there as 'this is my string.' etc...
>>>>
>>>>I don't need to know where in the memo field it is, just whether it is there or not.
>>>
>>>
>>>I did some testing now (I don't know how representative they are):
>>>
>>>
>>>CLEAR
>>>CREATE CURSOR crsTest (MyMemo M)
>>>APPEND BLANK
>>>REPLACE MyMemo WITH REPLICATE([A],16000000)+[ My String]
>>>
>>>m1 = SECONDS()
>>>AT([My String], MyMemo)
>>>? [AT], SECONDS()-m1                  && 0.047
>>>
>>>m1 = SECONDS()
>>>RAT([My String], MyMemo)
>>>? [RAT], SECONDS()-m1                 && 0.053
>>>
>>>m1 = SECONDS()
>>>aaa = [My String] $ MyMemo
>>>? [$], SECONDS()-m1                   && 0.045
>>>
>>>m1 = SECONDS()
>>>aaa = OCCURS([My String], MyMemo)
>>>? [OCCURS], SECONDS()-m1              && 0.284
>>>
>>>m1 = SECONDS()
>>>SELECT * FROM crsTest WHERE MyMemo LIKE [%My String%] INTO CURSOR aaaa
>>>? [SELECT +LIKE], SECONDS()-m1        && 0.980
>>>
>>
>>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.
>
>Tracy,
>In my tests $ was not the fastest (but it may be on different conditions, machines). at() and rat() were the fastest for me. The differences were almost negligible (I didn't see a difference more than 0.020).
>IMHO, using ATC() is better because it provides case insensitivity which is not available with $,like,occurs.
>Cetin

Thanks Cetin. I will do some more testing today. Normally I have to allow for a possible difference in upper or lower case, but for this, I know the exact case of the phrase because it comes from a single source.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform