Re: "mylist" vs "a reference to" - speed difference
Re: "mylist" vs "a reference to" - speed difference
- Subject: Re: "mylist" vs "a reference to" - speed difference
- From: Charles Arthur <email@hidden>
- Date: Fri, 26 Apr 2002 11:35:33 +0100
On Fri, 26 Apr 2002 08:59:49 +1000, Malcolm Fitzgerald
<email@hidden> wrote:
>
The ASLG says, use "my" to refer to objects inside handlers otherwise
>
applescript will initially treat the object as an undefined local
>
variable name.
>
>
I think you have put the "my" in the wrong spot. Try using this code
>
and running the test again:
(code snipped; in applescript-users digest, Vol 3 #393)
Oh yes. Using the ticks (on OS9, obviously) gave 18 vs 24 for 5000 reps.
... but gave 11 vs 14 when run inside a handler (with the lists as properties).
--Non-handler version:
------
set isalist to {}
set list2 to {}
set list3 to a reference to list2
set starttime to the ticks
repeat 5000 times
set end of my isalist to "2"
end repeat
set endtime to the ticks
set twostart to the ticks
repeat 5000 times
set end of list3 to "2"
end repeat
set twoend to the ticks
{(endtime - starttime), (twoend - twostart)}
----
--handler version
property isalist : {}
property list2 : {}
on run
dothings()
set whatis to the result
end run
on dothings()
set list3 to a reference to list2
set starttime to the ticks
repeat 5000 times
-- set end of isaList to "2"
set end of my isalist to "2"
end repeat
set endtime to the ticks
set twostart to the ticks
repeat 5000 times
set end of list3 to "2"
end repeat
set twoend to the ticks
{(endtime - starttime), (twoend - twostart)}
end dothings
Not that big a difference, though it's a difference.
Charles
----------------------------
http://www.ukclimbing.com : 1100+ British crags, 350+ British climbing
walls - searchable by distance and anything else you care to think of -
with weather forecasts for every one, plus maps, articles, news and
features. And there's even a cool shop attached.
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.