Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why write on array property is much faster a scalar propert
Message
From
13/08/2003 06:48:57
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Why write on array property is much faster a scalar propert
Miscellaneous
Thread ID:
00819717
Message ID:
00819717
Views:
59
Hi,

I have found VFP array faster of scalar . Why ?

Generally an Array is slower than one variable
( in fact read a property array is slower respect to read a scalar property).

But, you compare write on scalar property with write on array property,
it need 2.5 x times ! .
msg=''
SET TEXTMERGE ON TO MEMVAR msg NOSHOW
x=CREATEOBJECT("empty")
ADDPROPERTY(x,'mypro',0)
ADDPROPERTY(x,'amypro[1]',0)
mypro=0
DIMENSION amypro[1]
amypro[1] = 0
t1=SECONDS()
FOR ih=1 TO 1000000
NEXT
fixtime=SECONDS()-m.t1
t1=SECONDS()
FOR ih=1 TO 1000000
  =m.mypro
NEXT
\ read var <<SECONDS()-m.t1-m.fixtime>>
t1=SECONDS()
FOR ih=1 TO 1000000
  STORE 1 TO mypro
NEXT
\ write var <<SECONDS()-m.t1-m.fixtime>>

t1=SECONDS()
FOR ih=1 TO 1000000
  =m.amypro
NEXT
\ read array var <<SECONDS()-m.t1-m.fixtime>>
t1=SECONDS()
FOR ih=1 TO 1000000
  STORE 1 TO amypro
NEXT
\ write array var <<SECONDS()-m.t1-m.fixtime>>


t1=SECONDS()
FOR ih=1 TO 1000000
  =m.x.mypro
NEXT
\ read property <<SECONDS()-m.t1-m.fixtime>>
t1=SECONDS()
FOR ih=1 TO 1000000
  x.mypro = 1
NEXT
\ write property <<SECONDS()-m.t1-m.fixtime>>

t1=SECONDS()
FOR ih=1 TO 1000000
  =m.x.amypro
NEXT
\ read array property <<SECONDS()-m.t1-m.fixtime>>
t1=SECONDS()
FOR ih=1 TO 1000000
  x.amypro = 1
NEXT
\ write array property <<SECONDS()-m.t1-m.fixtime>>

SET TEXTMERGE TO
SET TEXTMERGE OFF 
MESSAGEBOX(msg)
I have test this also within a complex application.
Reply
Map
View

Click here to load this message in the networking platform