• 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
list-building performance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

list-building performance


  • Subject: list-building performance
  • From: Nigel Redmon <email@hidden>
  • Date: Fri, 1 Jun 2007 17:57:46 -0700

I expected that appending items to a list by setting (or copying to) the end of a list would be fairly efficient, but found it's not. It appears that the process grows with the size of a list, so that the time involved grows exponentially, at least with the ways I've tried so far. For instance, creating a list as follows take about 1 second for 500 loop iterations, 4 seconds for 1000, and 32 seconds for 2000:

set startTime to (time of (current date))
set theList1 to {}
set timeStamp to 0
repeat with idx from 1 to 2000
set end of theList1 to {timeStamp, noteOn, 60, 100}
set end of theList1 to {timeStamp + 1, noteOn, 60, 0}
set timeStamp to timeStamp + 1
end repeat
(time of (current date)) - startTime


If I split the job up, working in smaller chunks and concatenating them, performance goes up dramatically. For instance, I can do the same job in a second if I nest two loops, with the inner one building a smaller section and the outer loop concatenating the result into another list. Obviously, that's worth is, since the code only grows by a couple of lines and executes 32 times faster, but it seems like there should be a better way. Surely there must be an efficient way to append something to the end of a long list--am I missing something?

Thanks
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: list-building performance
      • From: "Mark J. Reed" <email@hidden>
    • Re: list-building performance
      • From: KOENIG Yvan <email@hidden>
  • Prev by Date: Re: Determine whether spot color is RGB or CMYK in Illustrator CS2
  • Next by Date: Re: list-building performance
  • Previous by thread: Re: GUI TextEdit
  • Next by thread: Re: list-building performance
  • Index(es):
    • Date
    • Thread