• 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: cost of repeats (was Re: why is applescript so slow???)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cost of repeats (was Re: why is applescript so slow???)


  • Subject: Re: cost of repeats (was Re: why is applescript so slow???)
  • From: "halloolli" <email@hidden>
  • Date: Wed, 1 Dec 2004 15:29:50 +1100

well, sure, it's obvious that counting twice costs more. but in my original example (which takes more than a minute) i'm counting to 200 (adressbook cards) not 100000! so, i'd think the main time is spend _inside_ the reapeat not with handling the repeat loop itself.

olli


----- Original Message ----- From: "Jake Pietrykowski" <email@hidden>
To: "halloolli" <email@hidden>; "wayne melrose" <email@hidden>; <email@hidden>
Sent: Wednesday, December 01, 2004 1:32 PM
Subject: Re: cost of repeats (was Re: why is applescript so slow???)



It's just logic really...with example (1) you'd be forcing the script to
count twice. Here...try this...got a stopwatch? j/k ;-)

(* start of script *)

set x to 100000

-- Script 1
set counter to 0

repeat with i from 1 to x
   set counter to counter + 1
   set counter to counter + 1
end repeat

-- Script 2
set counter to 0

repeat with i from 1 to x
   set counter to counter + 1
end repeat
repeat with i from 1 to x
   set counter to counter + 1
end repeat

(* end of script *)

While BOTH scripts will indeed generate the SAME results...on my PBG4
400mHz...100000 was a high enough number for me to get a 2.5 second count
for script 1 and a 3 second count for script 2. I'd imagine the faster your
machine, you'd have to keep adding zeros (0) to x so increase the script run
time.


Placing the REAL TIME test aside...its really just LOGIC. If x = 1,000,000,
why count from zero to 1 million twice? Counting alone takes time...remove
any script action and see the LOGIC.


(1)
repeat with i from 1 to 100
end repeat

OR

(2)
repeat with i from 1 to 100
end repeat
repeat with i from 1 to 100
end repeat

While the script does NOTHING in either case, script 2 must count to a total
of 200 before complete vs. script 1, a total count of only 100.


Hope this helps...

Kindest Regards,
Jake



On 11/30/04 8:06 PM, "halloolli" <email@hidden> wrote:

From: "wayne melrose" <email@hidden>

After a quick glance at your code, and I mean quick, I would suggest
trying to put your repeats into the same loop..

pardon, so, given the two scripts

(1)     repeat with i in theList
            do_one_thing
        end repeat
        repeat with i in theList
            do_another_thing
        end repeat

 and

(2)     repeat with i in theList
            do_one_thing
            do_another_thing
        end repeat



does your statement mean that script (1) is substantially slower then (2)?
well, i might do some tests, but in the meanwhile i want to ask: why does a
loop itself shall cost so much?


thanks, olli


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: cost of repeats (was Re: why is applescript so slow???) (From: Jake Pietrykowski <email@hidden>)

  • Prev by Date: Re: set variables, in mass
  • Next by Date: Re: cost of repeats (was Re: why is applescript so slow???)
  • Previous by thread: Re: cost of repeats (was Re: why is applescript so slow???)
  • Next by thread: Re: why is applescript so slow???
  • Index(es):
    • Date
    • Thread