Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP versus C++
Message
 
 
À
28/10/2003 01:41:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00842594
Message ID:
00843573
Vues:
22
Al,

>I now have a theory:
>
>ALINES() is fast, and it's a relatively new function in VFP.
>AT(), SUBSTR() etc. are slow, these are old functions, around since FoxBASE+ days.

Not true. at() is just a thin wrapper around a strstr() family function.

The performance of code degrades because of using the 3rd parameter to the at() ala:
for i = 1 to 10
   j = at( x, y, i )
endfor
which is an O(n2) algorithm. It makes the at() function internally run several times, the next iteration of the loop forces it into redoing the all same string seeks that it already found in the iteration before.

This sort of code construct:
for i = 1 to 10
   j = at( x, y )
   y = substr( y, j+1)
endfor
reduces the seek time by removing the repeated seeks, at the expense of moving lots of string memory around and some memory management in deallocating the used memory of y as it shortens. This also is O(n2) performance.

>I wonder if the "old" functions are still mired in the 16-bit world and are losing performance with 16/32 bit conversions ("thunking") and/or hitting limitations at 64K chunks? The moral - for fast VFP performance, use new functions??

No, at(x,y) in VFP is linear in performance O(n) where n length of string for n anywhere from a few thousand characters upto 16mb.

The alines() sort of code is O(n) because you only need to make 2 linear passes through the string, once to put it into the array and once to iterate the array.
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