Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CHRTRAN and remove characters
Message
 
 
To
14/10/2004 11:42:41
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00950654
Message ID:
00951455
Views:
9
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform