• 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: Settings backup script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Settings backup script


  • Subject: Re: Settings backup script
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 03 Aug 2001 13:52:41 +1000

On 3/8/01 12:05 PM +1000, Nigel Garvey, email@hidden,
wrote:

> It's the characters of a string that are counted by default, so 'number of
> MyComments', or 'length of MyComments', or 'count MyComments' will tell you
> how many characters there are in the string. The expression 'number of
> characters of MyComments' is the same as 'number of (characters of
> MyComments)'. It first makes a list of the individual characters - eg. {"H",
> "e", "l", "l", "o"} - and then counts the items in the list. The answer's
> exactly the same, but it uses more memory and takes a little longer.

I'm not entirely convinced of this, although I'm open to persuasion. But if
I run the following script:

set x to "The wiley brown fox scripted his way around the lazy black dog."
set time1 to the ticks
repeat 10000 times
set a to characters of x
end repeat
set time2 to the ticks
repeat 10000 times
set a to count of characters of x
end repeat
set time3 to the ticks
repeat 10000 times
set a to length of x
end repeat
set time4 to the ticks
repeat 10000 times
set a to count of x
end repeat
set time5 to the ticks
{time2 - time1, time3 - time2, time4 - time3, time5 - time4}

I typically get something like {117, 13, 12, 10}. This suggests to me that:

(a) "count of characters of" doesn't actually build a list, given how long
just building a list takes;

(b) getting "length of" is not appreciably faster than "count of characters
of"; and

(c) although "count of" is the fastest method, there's not much in it.

I guess this might be one of those things that varies with AS versions, and
the test is simplistic, but the difference between the first two times is
pretty dramatic.

--
Shane Stanley, email@hidden


References: 
 >Re: Settings backup script (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: applescript-users digest, Vol 2 #924 - 16 msgs
  • Next by Date: How do I set script property in another script?
  • Previous by thread: Re: Settings backup script
  • Next by thread: Re: Settings backup script
  • Index(es):
    • Date
    • Thread