Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Write on scalar property use a slow search routine.
Message
From
28/09/2003 12:49:51
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
28/09/2003 11:46:26
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00833001
Message ID:
00833017
Views:
26
Yes, that is the way VFP works. The problem is that it has to find variables (or properties) in a list of names.

A true compiler would change the names to memory locations at compile time. VFP doesn't. This means that for certain things, VFP is quite slow.

>Hi,
>
>Finally I have found the time in order to write a procedure that explain the low efficiency of the ruotine that writes a value on one scalar property.
>
>Premised:
>when VFP must read or write on one object property, VFP searches the property in the list (an inner Array with max 64000 items) of the names of the properties of the object.
>The used method is one linear scansion.
>The names of the scalar property and Array property are in the same list.
>
>Strangely the time necessary for the search scansion of a scalar property to write, turns out double of the normally necessary time.
>
>In order to measure this effect, it is necessary to create a high number of properties:
>
>clear
>RELEASE all
>_SCREEN.FontName="Courier new"
>SET DEVICE TO SCREEN
>nCycle = 10000
>x=CREATEOBJECT('empty')
>* internal array is filled with interleaved array,scalar properties
>FOR k=0 TO 9999
>	=ADDPROPERTY(m.x,"array"+PADL(LTRIM(STR(m.k,5)),5,"0")+"[1]")
>	=ADDPROPERTY(m.x,"scalar"+PADL(LTRIM(STR(m.k,5)),5,"0"))
>NEXT
>
>@ $  ,0 say "Item   | Scalar Read   | Scalar Write |  Array Read  | Array Write   "
>@ $+1,0 say "-------|---------------|--------------|--------------|---------------"
>@ $+1,0 say "First   "
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.scalar00000
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.scalar00000 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3) STYLE "B"
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.array00000
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.array00000 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>
>@ $+1,0 say "Middle  "
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.scalar04999
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.scalar04999 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3) STYLE "B"
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.array04999
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.array04999 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>
>@ $+1,0 say "Last    "
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.scalar09999
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.scalar09999 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3) STYLE "B"
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> =x.array09999
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>T1=SECONDS()
>FOR jui=1 TO m.nCycle
> x.array09999 = .T.
>NEXT
>@ $,$ say STR(SECONDS()-T1,15,3)
>
>* Result on my machine
>*Item   | Scalar Read   | Scalar Write |  Array Read  | Array Write
>*-------|---------------|--------------|--------------|---------------
>*First             0,010          0,010          0,010          0,010
>*Middle            0,370          0,701          0,361          0,360
>*Last              0,741          1,452          0,761          0,761
>
>
>Even if with a number of normal properties, this slowing down is not measurable, it exists.
>
>I hope that the VFPT controls the code and can resolve this strange behavior (a lot penalizing).
>
>Thanks
>
>Fabio
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform