![]() Instead, use whose clauses to get the server application to do the iteration for you. The most common mistake is to iterate over application objects using AppleScript. Reducing the number of Apple events will significantly speed up your script. A System 7 application can process at most 60 events per second, with typical performance more like 20-40 events per second. Under System 7, Apple event performance is poor. Keep the number of Apple events your script generates to a minimum. Install Speed Doubler if you are on a PowerPC. Here are some tips and ideas for making scripts run faster. Probably the most frustrating part of using AppleScript is watching its seemingly slow progress through your script. If youre using Scripter, turn off its allow background compiles preferences option. Avoid having the Finder perform folder size calculations, turn off personal file sharing, etc. If you keep this to a minimum, your compiles will be faster. All the script editors allow some level of background activity during compiles. A PowerPC-native script editor helps here (Script Debugger, Script Wizard), but its always going to be an issue. For short scripts, its not really an issue, but for scripts larger than about 100K it can represent as much as a couple of minutes of the total compile time. This point becomes more important as the size of your scripts grow. The answer is to keep the number of formats you use to a minimum. The slowdown is caused when your script editor is forced to cope with growing numbers of style runs as it displays your script following a compile. Unfortunately, the more formats you use, the slower your compiles will be. The formatted text feature of AppleScript is the only really good way to understand how AppleScript has interpreted your script during compilation. Once youve loaded your library, you can access properties and call handlers stored within it like this: Property lib1 : load script (projectPath & "Lib1") «property ctnr» of item (path to me) of ¬ If youre using Script Debugger, you can use its path to me handling to store your libraries in a folder with your script: Property lib1 : load script alias "My HD:Script Libraries:Lib1"Īlternatively, you can store your libraries in the same folder as your script editor, and load them with the following command: If youre using Script Editor, Script Wizard, FaceSpan or Scripter, its probably best to store your pre-compiled scripts in a known location so that you can use simple Load Script statements: Use the load script command to load pre-compiled portions of your script project. ![]() This happens when a term is defined by two different scripting additions. Also, more scripting additions means more event and class names must be parsed from 'aete' resources and added to the AppleScript symbol table.Ī side benefit of keeping the number of scripting additions to a minimum is that you are less likely to run into terminology conflicts. Having too many scripting additions slows AppleScripts load time, since it must process that many more files in the Scripting Additions folder. Keep the number of scripting additions to a minimum. My customers have reported a 2 to 4 times improvement in AppleScript performance with Speed Doubler installed. ![]() Buy Speed Doubler if you are using a PowerPC-based Macintosh. Here are some tips for keeping compile times as short as possible: Regardless of what script editor you are using, you are bound to get to the point where you wish scripts would compile faster. Depending on the kind of scripts you are working on, these improvements in performance may turn out to be dramatic. This article provides a number of tips for improving the performance of your scripts. However, theres something else wrong, apparently, because even AppleScript scripts which dont generate any Apple events do not seem to perform as well as similar scripts written in Frontier. In my tests, there clearly are limits to the number of round-trip Apple events you can push through the system per second. The reason given by Apple is that the Apple event mechanism used by AppleScript to communicate with other applications has serious performance limitations under System 7. This is the question our customers ask most frequently, and one to which there is no simple answer. Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks. Educational Institution and Student DiscountsĪS Performance Volume Number: 12 Issue Number: 5 Column Tag: Applescript.
0 Comments
Leave a Reply. |