Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LEN() function - ugly implementation or bug?
Message
De
26/12/2003 09:46:44
 
 
À
26/12/2003 09:14:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00862121
Message ID:
00862124
Vues:
14
Hi Fabio,

I suspect the results of len() are due to the fact that vfp passes the arguement by value, ie each time it calls len() it has to (1) create/copy the arguement and (2) release the arguement upon return.

So it is not len() by itself that is slow, but the preparation involved to get to it is slow

Gregory
___________________________
>Hi,
>
>Preface:
>
>I can do this sum:
>
>x = x + y
>
>
>with this algorithm ?:
>
>for iLoop=1 to y
>   x = x +1
>endfor
>
>
>Yes, but it is a hugly implementation,
>and if i can do it faster without effort, it is a bug for me.
>
>Well.
>
>Why on VFP LEN() function use a similar algorithm for return the lenght
>of a string ?
>
>VFP use binary strings; it do not use a end string special character.
>Then, the lenght of the string is on the internal "value structure"
>of the variable string ( like on Pascal ).
> API section of the help reference to this value with:
> cVal->ev_length syntax.
>
>Then, i aspected LEN() speed independent by the lenght of the string,
>as a O(1) complexity,
>but this is not true,
>it is a O(N) complexity.
>
>Run this:
>
>CLEAR
>SET ESCAPE ON
>
>memString = SPACE(1)
>t1=SECONDS()
>FOR j=1 TO 5000000
> 	strLenght = LEN(m.memString)
>NEXT
>? TRANSFORM(5000000/(SECONDS()-m.t1),'@R string lengh = 1 999,999,999,999 vfops/s')
>
>memString = SPACE(10000000)
>t1=SECONDS()
>FOR j=1 TO 100
> 	strLenght = LEN(m.memString)
>NEXT
>? TRANSFORM(100/(SECONDS()-m.t1),'@R string lengh = 1000000 999,999,999,999 vfops/s')
>
>* for 1 -> 2.143.163 vfops/s
>* for 1 ->        33 vfops/s
>*  slow down by 65.000 times ( this is not 10000000 for VFP overhead and Hardware caching )
>
>
>If VFP9 remove the 16MB string lenght limit, to get the LEN() of a 2GB string
>can require many seconds !
>
>Post notes:
>I see various comparison between VFP and .NET,
>but this is only a relative comparison; like to compare :
>
>a) a photon with a electron particles,
>b) a F-16 Airforce with a Piper airplanes,
>c) a Ferrari with a Fiat cars
>d) a tortoise with a snail animals.
>
>Photon is the best real limit!
>
>Somebody known if the best VFP and .NET comprison analogy is a),b),c) or d) ?
>
>One or two past years, i thought b), but with the recent experiences ....
>
>Fabio
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform