• 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: "idle" has different effect in X vs 9?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "idle" has different effect in X vs 9?


  • Subject: Re: "idle" has different effect in X vs 9?
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 8 May 2003 17:11:43 -0700

The explanation, or at least part of it, was mentioned last week in relation to something else. (Something about script applications running slightly slower than in Script Editor, as I recall.) AppleScript's "delay" command is implemented by simply calling what's known as the "active proc" over and over until the specified time has elapsed. (The active proc is what allows an application to do other stuff while a script is running, such as redraw windows, check for you pressing command-period, etc.)

Because of how Script Editor 1 implemented its active proc, it sucks up all the CPU it can get when you use "delay". Applets are more polite, and consume only a little CPU. 'do shell script "sleep"' just calls sleep(3), which is almost perfectly efficient -- zero CPU usage.

It turns out that Script Editor 2 has the same problem as Script Editor 1 -- I'd claimed otherwise last week, so I've filed a bug.

--Chris Nebel
Apple Development Tools

On Thursday, May 8, 2003, at 01:11 PM, Rob Morton wrote:

I figured I would ask the rest of the list if they have an explanation for some findings as well. These show the processor usage for using either delay 10 or do shell script "sleep 10" as an Application or from inside of Script Editor. This is completely a pointless exercise of course, but it does seem odd.

Here are some result using top to follow the usage...

delay 10 in an application:
28713 Delay.app 2.5% 0:00.88 1 47 123 1004K 9.17M 5.29M 71.5M

do shell script "sleep 10" in an application:
28723 Delay.app 0.8% 0:00.95 1 46 122 992K 9.24M 5.30M 71.2M

delay 10 from script editor:
28672 Script Edi 67.7% 0:18.52 2 89 194 3.81M 19.2M 11.8M 87.1M

do shell script "sleep 10" from script editor:
28672 Script Edi 1.6% 0:13.43 2 87 194 3.81M 19.2M 11.8M 87.1M

on 5/8/03 10:58 AM, Bill Cheeseman at email@hidden wrote:

on 03-05-08 9:47 AM, Rob Morton at email@hidden wrote:

Since you have had two suggestions for using delay 10, now would be a nice time to point out that the amount of CPU that delay seems to use is amazing.
A one line AppleScript of
delay 10
seems to keep my CPU usage at about 70% according to top
do shell script "sleep 10"
doesn't even register in my top apps, but does the exact same thing.

The intent of 'delay' was to leave the CPU free to perform other tasks, and it has worked well for many versions of AppleScript. I don't know how to explain your 70% CPU usage figure. Are you sure it isn't caused by something else?

I just saved this script as an applet, ran it, and got a reading from Process Viewer between 0.10% and 4.10%. A number of other applications and processes were running, but none was doing much of anything.
_______________________________________________
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.

  • Follow-Ups:
    • Re: "idle" has different effect in X vs 9?
      • From: Stephen Swift <email@hidden>
    • Re: "idle" has different effect in X vs 9?
      • From: John Delacour <email@hidden>
    • Re: "idle" has different effect in X vs 9?
      • From: Shane Stanley <email@hidden>
References: 
 >Re: "idle" has different effect in X vs 9? (From: Rob Morton <email@hidden>)

  • Prev by Date: Re: Order of operations (was: Eigenvalues &/or eigenvectors,
  • Next by Date: Powermac4u
  • Previous by thread: Re: "idle" has different effect in X vs 9?
  • Next by thread: Re: "idle" has different effect in X vs 9?
  • Index(es):
    • Date
    • Thread