Re: do shell script speed (URL Access Redux)
Re: do shell script speed (URL Access Redux)
- Subject: Re: do shell script speed (URL Access Redux)
- From: Christopher Nebel <email@hidden>
- Date: Tue, 23 May 2006 11:59:00 -0700
On May 23, 2006, at 2:48 AM, Emmanuel wrote:
At 10:49 AM -0700 5/22/06, Roger Howard wrote:
On a tangent, I do think we need some statement from the listmom
(or whomever) about the suitability of do shell script-based
solutions here, as this debate has come up several times recently.
I personally believe this is a perfectly relevant type of solution
for this list, and like any other offered solutions it is up to
the requester to determine if it's appropriate for their needs. I
cannot even count the number of times I've used do shell script
where no other solution worked. I also don't believe that shell
commands are, in the abstract, any more of a stretch to learn for
people already writing scripts, and it's a very powerful facility
in OSX that has enhanced AppleScript in innumerable ways.
The big problem with do shell script is that it is awfully slow. We
publish a page about that at:
<http://www.satimage-software.com/test_05_08/speed_test_result.html>
Since you keep mentioning this in public, I might as well give you
the answer in public, too:
I measured the slowdown between 10.3 and 10.4 at about 2x, not the 4x
you claim. Your methodology is somewhat flawed, because "beep" is
actually very expensive and time-consuming as scripting additions
go. "ASCII number" or "ASCII character" would have been a better
choice, but an even better choice would have been to use Sampler or
Shark, since that's what they're there for.
The slowdown is entirely attributable to a switch from vfork(2) to
fork(2) to create the new process. This was done for reasons of
correctness -- "do shell script" does things in between the fork and
the exec that are not allowed, but which happened to work in 10.3.
Did you want it to be fast, or did you want it to work?
That said, the basic advice -- don't use a lot of little "do shell
script" calls -- would have held even with the vfork(2)
implementation. Creating a new process will involve kernel calls,
file I/O, and millions of instructions executed, and if all you
needed was a number converted from hex to decimal, it's kind of a
waste. However, if you just want to write something quickly and it
runs "fast enough", then go for it. While "performance" can be
measured objectively -- which one is faster? -- practically speaking,
it's subjective -- is it fast enough? -- and must be weighed against
how much trouble you have to go through to make it fast.
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
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