Re: Not so sure
Re: Not so sure
- Subject: Re: Not so sure
- From: email@hidden
- Date: Fri, 25 Jan 2002 23:35:30 -0500
Fri, 25 Jan 2002 17:23:38 -0500
email@hidden (Michael Sullivan)
asked,
>
Do osaxen have any speed advantages over apps?
>
>
It strikes me that they don't -- they still involve an apple event call,
>
it's just to the system instead of an app. Maybe that makes it
>
marginally faster, but it still takes aeons compared to a straight
>
language command.
There is a definite speed advantage, because you don't have to wait for a
process switch. My rule of thumb is that an interapplication call is an order
of magnitude slower than an osax call, and an osax call is more than an order of
magnitude slower than an AppleScript function call. (Of course, you expect an
osax to do something useful and powerful, so the overhead of the call is
negligable. "ASCII character" is not a good example of that.)
I ran a test script that compared a function call within the script, an osax
call within the current process, an osax call to another process, and a regular
Apple Event to another process. Here are the timings, in microseconds per call,
rounded to the nearest microsecond:
handler call--self 19 5s foo(x)
osax call--self 867 5s ASCII character 42
osax call--other 8797 5s ASCII character 42 (to Finder)
Apple Event--other 11683 5s get its name (to Finder)
The test script was like this (requires Jon's command for "the ticks")
property N : 6000
set t0 to the ticks
repeat N times
foo(17)
end repeat
set t1 to the ticks
tell application "Finder"
repeat N times
ASCII character 42
end repeat
end tell
set t2 to the ticks
tell application "Finder"
repeat N times
get its name
end repeat
end tell
set t3 to the ticks
repeat N times
ASCII character 42
end repeat
set t4 to the ticks
set k to 1000000 / 60 / N
return {k*(t1-t0), k*(t2-t1), k*(t3-t2), k*(t4-t3)}
to foo(x)
return 42
end foo
--
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