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 11:46:26
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Write on scalar property use a slow search routine.
Miscellaneous
Thread ID:
00833001
Message ID:
00833001
Views:
55
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
Next
Reply
Map
View

Click here to load this message in the networking platform