• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: processing time & stack overflow!!!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: processing time & stack overflow!!!


  • Subject: RE: processing time & stack overflow!!!
  • From: monk <email@hidden>
  • Date: Sun, 02 Sep 2001 03:28:35 -0400

-- 8/31/01 8:03 AM: email@hidden said:

> On Fri, 31 Aug 2001 04:24:15 -0400, monk wrote,
>
>> can you explain/share to/with us what you did to
>> make the script go from an average of 12 minutes to (on my machine) 12
>> seconds
>
> I basically did what Arthur was telling us to do:
>
> 1. use his handler ;)
> 2. use a reference to the reallyBigList

well then, i guess arthur us some kind of scripthead deity in my book!
>
> 1. A script usually consists of two types of commands: those handled
> internally by AppleScript (basic math, strings, lists...) and those that are
> handled externally by an application or scripting addition. With the latter,
> AppleScript has to send a message to the receiving application or osax to
> process the command, and then get a message back containing the results.
>
> In the case of "random number", that command belongs to the Standard Additions
> osax (osax is another term for scripting addition). Because of this, when a
> script invokes the command, it incurs an overhead of two messages; one to say
> "hey, Standard Additions, give me a random number" and the other to say
> "thanks, that random number is just what I needed." Normally, this overhead is
> barely noticed because it takes a small fraction of a second to perform, but
> when repeated thousands of times...
>
> So, using Arthur's handler reduced that overhead from thousands of repetitions
> to just one (he's a smart guy).
>
> 2. When manipulating very large lists in AppleScript, there's a method that
> can be used to reduce processing overhead: a reference to someReallyBigList.
>
> Now, this is something that I use but don't really fully understand, so I'm
> the wrong guy to answer. But it seems that when manipulating lists, the
> "reference to" construct will save considerable amounts of processing.
>
> I would guess that it has something to do with reassigning memory. That when
> directly manipulating a list, e.g. setting the contents of item 1 to the
> contents of item 2, AppleScript has to: assign memory to hold a copy of the
> contents of item 2, assign the new memory address to item 1, and then release
> the old address.
>
> Whereas with "reference to", it just tells item 1 "you see where item 2 's
> contents are in memory? Ok, that's what your contents are supposed to be as
> well."
>
> But I'm just guessing. Fortunately, you can use "reference to" without needing
> to understand how it's _implemented_. All you need to do is understand how it
> _behaves_ (we'll leave the ugly stuff of impementation to the AppleScript
> team).
>
> In any case, all thanks for the improved performance of the "cross cutting"
> script should go to Arthur (hey, he really is a smart guy! ;)
>
i agree and thanks for that succinct description!

> Victor
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users

h 'monk' elmer
--
| , , , , , , , , , , , |
http://www.assemblage.org
| |


  • Prev by Date: Re: Sort items in a list without OSAXen
  • Next by Date: Palm Desktop
  • Previous by thread: Re: processing time & stack overflow!!!
  • Next by thread: Re: processing time & stack overflow!!!
  • Index(es):
    • Date
    • Thread