Re: Speeding Up Scripts 101
Re: Speeding Up Scripts 101
- Subject: Re: Speeding Up Scripts 101
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 03 Mar 2002 20:18:26 -0800
On 3/3/02 8:05 PM, "James Sentman" <email@hidden> wrote:
>
I would very much like to find a repository of script speed info.
>
>
I'll start you off with one;) I'm trying to shave some seconds off
>
the code that generates these rather large tables for a motion sensor
>
report.
>
>
The code does a lot of things like:
>
>
set MyOutput to MyOutput & "some more data" & return & "a little bit more"
>
>
After doing a bunch of experimenting I've found that doing:
>
>
set MyOutput to {MyOutput, "some more data", return, "a littlemore"} as string
>
>
is considerably faster. I tried various other things, like just
>
creating one long list and coercing it to a string at the return
>
statement, but that was slower than the concatenation. I also tried
>
statements like:
>
>
copy {"some more data", return, "a little more"} to the end of MyOutput
>
or
>
set the end of MyOutput to {"some more data", return, "a little more"}
>
>
but that also wasn't as fast.
Don't use 'copy' except when you're changing items of the original list and
don't want to change them in a copied list: it's meant to be demanding on
memory.
You can build your list, without 'return', throughout the progress of your
script, like this:
set MyOutput to {}
repeat with i from 1 to 2000
set end of MyOutput to "some more data " & i -- or whatever
end repeat
set AppleScript's text item delimiters to {return}
set MyOutput to MyOutput as string
set AppleScript's text item delimiters to {""}
MyOutput
Test it and see if this is an improvement.
--
Paul Berkowitz
_______________________________________________
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.