Re: Is there any difference in accessing a variable vs object's proper
- From: "Olaf Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU.strconv.14@xxxxxxxxxxx>
- Date: Fri, 10 Nov 2006 09:28:57 +0100
I want to know whether there is any difference (such as performance) in accessing a variable which has been assigned the value of an object's property vs the object's property?
Accessing a property of an object has to lookup
Object reference pointer, then find the property
in the objects structure. So accessing the
variable copy can be faster, but that variable has to
be generated and then filled with that value of
the property. And finally, if you change the
value it has to be reassigned to the objects
property again.
Also acessing a variable can be slow, if you dont
use m dot. Accessing myVariable can be much slower
than accessing m.myVariable, as read acess of a
name expression first will first search, if there is a
field in the active workarea. With Write Access
that is not the biggest problem, but STORE
value To m.myVariable can be faster than
m.myVariable = value.
So using a var the right way could speed up tight
loops over many records or array rows, as the overhead
of first copying the value to a var is low compared to
overall saved time. But WITH..ENDWITH also helps
to cut the path to the objects structure, especially
with something nested as thisform.pageframe1.
pageX,pageframe1.PageY....
Write a testcase and see yourself:
pseudocode:
1.
t1=seconds()
var=object.property
loop
... var
endloop
?seconds()-t1
2.
t1=seconds()
var=object.property
loop
... m.var
endloop
?seconds()-t1
3.
t1=seconds()
loop
... object.property
endloop
?seconds()-t1
4.
t1=seconds()
with object
loop
... .property
endloop
endwith
?seconds()-t1
Bye, Olaf.
.
- Follow-Ups:
- Re: Is there any difference in accessing a variable vs object's proper
- From: Roger Ansell
- Re: Is there any difference in accessing a variable vs object's proper
- Prev by Date: Re: How to execute function in a Visual FoxPro dll within a SQL query?
- Next by Date: Re: Advertising jobs
- Previous by thread: Re: Is there any difference in accessing a variable vs object's proper
- Next by thread: Re: Is there any difference in accessing a variable vs object's proper
- Index(es):
Relevant Pages
|