I’m currently re-doing AutoRate in Objective-C. I’ve heard from a few users with very large libraries (20,000+) that the current version takes several hours to go through their entire library. Should be able to do much better than that in Obj-C instead of AppleScript.
Should give me more scope to do some other things as well, as I’m more comfortable with Obj-C than AppleScript. One feature I’m considering is live updating of ratings – AutoRate runs in the background and watches tracks that are played. That will yield the ability to form more accurate ratings, instead of having to use a couple of heuristics to ‘guess’.
So, stay tuned.
One Comment
Comments are closed.
Regarding using ObjC in place of AppleScript, check out objc-appscript if you haven’t already done so:
http://appscript.sourceforge.net/objc-appscript.html
However, don’t expect a straight translation from AS to ObjC to automatically provide vast performance improvements. While the AppleScript language certainly has its share of performance problems, Apple event IPC has various bottlenecks of its own which you need to be aware of.
Basically, there are two problems dealing with large data sets in AppleScript:
1. The first is that iterating over AS lists normally has O(n*n) efficiency, although there are known kludges you can use to get it down to O(n).
Alternatively, switching to another language (Python, Ruby, ObjC, etc.) lets you avoid that problem entirely.
2. The second is the overheads associated with Apple event IPC. While sending interprocess events is much more efficient than in pre-OS X days, it’s still slow compared to local procedure calls. It can also take a non-trivial amount of time for the target process to resolve object specifiers and perform commands.
Switching languages won’t help you here; your only option is to minimise the number of events you send wherever possible, e.g. sending a few more complex events:
is far, far more efficient than sending many simpler ones:
There are some notes about performance optimisation in the appscript documentation, and I think Matt Neuburg also discusses these issues in his AppleScript book.
HTH
has
—
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
Thanks for the great tips! I’ll check those things out – it’d be nice to reduce the bottleneck that is AS as much as possible.
This is great – Appscript is going to save so much time. I’m glad you mentioned it!
Great stuff! I say thnx and looking forward of the next release.