Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CHRTRAN and remove characters
Message
 
 
À
14/10/2004 11:42:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Divers
Thread ID:
00950654
Message ID:
00951455
Vues:
10
Fabio,

>Fast is a relative concept.
>A O(n)*1s or O(n)*1ms are two different thing.

Yes, if I had code that took one second per n I wouldn't run very large values of n through the code. That should be pretty obivious to everyone.

>>CHRTRAN() is already fast enough under the LEN(param2)=LEN(param3) condition, so no other alternate code is required. VFP has O(n) performance when doing character for character substitution.
lcStr = "abcdefghijklmnop"

for i = 1 to 6
   lcStrTran = replicate( lcStr, 10 ^ i )
   ltStart = seconds()
   lcX = chrtran( lcStrTran, lcStr, lcStr )
   ltStart = seconds() - ltStart
   ? i, len( lcStrTran ), ltStart
endfor
Even on this cruddy 2gh Celeron box VFP does 16 million character translations and puts it in the output buffer in 0.73 seconds so that makes it 0.045625 microseconds per n.

So, tell us all how right to left would make it any faster, much lest a thousand times faster... please we are all curious.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform