latency in services vs. script editor

This is basically instantaneous.

do shell script "open -a Terminal"

However. If you go to Automater, create this Service (run apple script from anywhere) with the same command. Then bind that to an arbitrary keyboard shortcut in System Preferences, using the shortcut to execute the SAME one line command is noticeably slower. Maybe it is like 300 milliseconds as opposed to 10 milliseconds or less.

Can anyone explain why this is or offer an alternative to make scripts run without this delay?

Don’t use Automator; it adds a lot of overhead. Try FastScripts instead.

Holy shit. This is a lifesaver. Thanks!

Apart from the overhead of Automator, services does a clean launch of your automator action each time including a clean launch of AppleScript. Your AppleScript-Editor/FastScript application has already a running version of AppleScript who also have already loaded the Standard Addition.osax. The script can be started right away with minor preparations. Not sure how much but you could gain some performance by simply using:

tell application "Terminal" to launch

It will avoid the requirement of the ascr/gdte event.

The equivalent to ‘open -a Terminal’ would be:


tell application "Terminal" to activate

There is no equivalent unfortunately.

‘open -a Terminal’ will send and open («event aevt/oapp») command when the application is not running, it will send an reopen («event aevt/rapp») when the application is running. It will activate the application before sending an reopen command but without sending any AppleEvent, it will also launch the application before sending the open command without using any AppleEvent. The commands that sends open or reopen events are run, reopen, launch and activate, but the last two sends additional AppleEvents which open shell command doesn’t. Therefore there is no equivalent but activate comes close even though it does the order of commands in the wrong order and only when the application is already running.