• 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: Script Speed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script Speed


  • Subject: Re: Script Speed
  • From: Alex Zavatone <email@hidden>
  • Date: Mon, 12 Nov 2012 10:40:35 -0500

One detail that I remember from back then that still might be relevant is regarding the sleep command.

Don't know if it still applies today, but it certainly might.

Several releases of the Mac OS back, using sleep when a script is run in the Script Editor, would fully max out the processor thread that the process is running on.  This was fixed, but then I found out that when running in a saved Script Editor app, the same thing would happen.

This was also fixed.

But then, when moving my scripts into a compiled Xcode app, the same thing would happen.

This isn't good if you need to use sleep often and if you ever are running your app on a laptop on battery power.  Nothing like being in a meeting with your laptop's fans whirring away loudly as you watch the battery's charge fade away as your script runs.

Because of this, I'll use the UNIX sleep command called from a shell script.  This will be wrapped in an on DoSleep(sleepDurationInSeconds).

One benefit is that you can sleep for .5 seconds using this approach.

Another is that it doesn't max out the core that the app's thread is running on.

From the sleep command's UNIX man file:

     The sleep command will accept and honor a non-integer number of specified
     seconds (with a `.' character as a decimal point).  This is a non-porta-
     ble extension, and its use will nearly guarantee that a shell script will
     not execute properly on another system.

Cheers.
 _______________________________________________
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

References: 
 >Script Speed (From: Paul Abney <email@hidden>)
 >Re: Script Speed (From: Shane Stanley <email@hidden>)
 >Re: Script Speed (From: Paul Abney <email@hidden>)
 >Re: Script Speed (From: Shane Stanley <email@hidden>)
 >Re: Script Speed (From: Paul Abney <email@hidden>)
 >Re: Script Speed (From: John <email@hidden>)

  • Prev by Date: Re: Script Speed
  • Next by Date: Re: sort lines in TextWrangler
  • Previous by thread: Re: Script Speed
  • Next by thread: Mail script for grouping messages?
  • Index(es):
    • Date
    • Thread