Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Recompile AppleScript apps for a speed boost System 10.6
AppleScripters should re-save their AppleScript .apps in the 10.6 AppleScript Editor so they run in 64-bit mode.

I keep an app on my Finder window toolbar that simply tells Finder to empty the trash; it was so old (having been transferred from previous machines) it may have originally been a PowerPC app. It, and quite a few other AppleScript apps, run significantly faster after I re-compiled them under Snow Leopard.
  • Currently 1.22 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (9 votes cast)

10.6: Recompile AppleScript apps for a speed boost | 5 comments | Create New Account
Click here to return to the '10.6: Recompile AppleScript apps for a speed boost' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Recompile AppleScript apps for a speed boost
Authored by: stokessd on Sep 16, '09 08:21:19AM

That's good to know, thanks.

I use <cmd><shift><backspace> to empty the trash, even faster than a script or reaching for the trackpad/mouse.


[ Reply to This | # ]
64 bit?
Authored by: bankshot on Sep 16, '09 08:53:07AM

I think the 64-bit mania is getting a little bit out of hand. AppleScript is certainly such a lightweight application that I can't possibly see it benefiting from running as 64-bit. I ran a few tests of my own scripts, and didn't find any difference in runtime between the standard 32-bit versions and 64-bit. It's easy to run your own test:

First, save the script as an application in Script Editor. Then in Terminal, change to the compiled AppleScript's "MacOS" directory. For example:

% cd

A compiled AppleScript should have 3 architectures in the "applet" executable. You can verify this with the "file" command:

% file applet
applet: Mach-O universal binary with 3 architectures
applet (for architecture x86_64): Mach-O 64-bit executable x86_64
applet (for architecture i386): Mach-O executable i386
applet (for architecture ppc7400): Mach-O executable ppc

Use the "lipo" command to extract individual executables of each architecture, and rename the existing executable to move it out of the way.

% lipo applet -extract x86_64 -o applet.x86_64
% lipo applet -extract i386 -o applet.i386
% lipo applet -extract ppc7400 -o applet.ppc7400
% mv applet applet.all

Now, to test any architecture, use the "ln" command to make a symbolic link (alias) to that executable named applet. For example, to test the i386 architecture:

% ln -sf applet.i386 applet

Try the different architectures and see if there's really any difference between i386 (32-bit) and x86_64 (64-bit). I couldn't find any.

I suspect the speedup has more to do with running the script natively rather than under Rosetta. I didn't install Rosetta on my Snow Leopard partition, so when I went to run an old script, it popped up asking if I wanted to install it. I recompiled the script instead. So I can't test the ppc architecture.

[ Reply to This | # ]
The much more likely reason
Authored by: boredzo on Sep 16, '09 10:13:17AM

The much more likely reason for the speed boost is that the script application was previously a PowerPC-only application, so you were running it in Rosetta. If you hadn't had Rosetta installed, it wouldn't have even worked (it would have asked you to install it). When you re-saved it, it became Intel-native, so it no longer needed Rosetta. The 64-bit-ness had nothing to do with it.

BTW, you need to use Save As to make this work.

[ Reply to This | # ]
10.6: Recompile AppleScript apps for a speed boost
Authored by: D-Man on Sep 16, '09 10:42:15AM

I agree with the previous posters that the speed up is from running natively rather than by way of Rosetta. I also found while running 10.5.x, if a script application is saved from Script Editor as an Application Bundle, it will be saved as a Universal and run considerably faster than it would if it had been saved as an Application.

Note: the option to save a file as an Application Bundle was renamed to Application in 10.6 meaning that in 10.6, Applications are saved by default as Application Bundles.

[ Reply to This | # ]

10.6: Recompile AppleScript apps for a speed boost
Authored by: TigerKR on Sep 17, '09 12:45:49AM

Wow, this makes a huge difference! It works for Automater applications too!

I doubt that it's just the 64-bit compile that makes a difference. It's probably that the scripts saved in Snow Leopard are optimized for Grand Central Dispach and OpenCL. Or maybe they're just compiled to use the newer Cocoa frameworks and not the older carbon frameworks.

Well, some combination of the above makes the applescripts and automater applications MUCH faster and smoother!

Thanks OP!

[ Reply to This | # ]