• 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
Speed of applets vs. compiled scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Speed of applets vs. compiled scripts


  • Subject: Speed of applets vs. compiled scripts
  • From: email@hidden
  • Date: Mon, 28 Jan 2002 12:09:36 -0500

On Mon, 28 Jan 2002 11:18:36 -0500, "Marc K. Myers" <email@hidden> asked,

> I wrote a little script to generate a list of all the prime numbers from
> 2 to 10001. I ran it under Script Editor and it took 586 seconds. Just
> out of curiosity I ran the same script as an applet. It ran for 998
> seconds! Can anyone tell me why there is such a difference?

Just guessing, but in a cooperative multitasking environment, the applet shell
seems to be more cooperative than Script Editor.

> I had
> expected the applet to run faster since it didn't have the overhead of
> the Script Editor application. Also, is there a faster algorithm for
> generating a list of primes?

You only have to try divisors up to sqrt(i), rather than i/2. As i gets large,
the savings are significant. (Specifically, you get an advantage of sqrt(i)/2.)
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden


  • Follow-Ups:
    • Re: Speed of applets vs. compiled scripts
      • From: "Geoff Canyon" <email@hidden>
  • Prev by Date: Break into a timeout loop
  • Next by Date: Problems with speed & issues with coercion in OS 9.2.2 (AppleScript 1.7)
  • Previous by thread: Speed of applets vs. compiled scripts
  • Next by thread: Re: Speed of applets vs. compiled scripts
  • Index(es):
    • Date
    • Thread