I’ve noted performance differences between scripts run from Script Editor and from an applet, PreTech - although nothing quite as extreme as your experience. (Perhaps closer to 30-40% in general cases and, anecdotally, up to 300% in the case of Illustrator - which is certainly bad enough.) There was an acknowledged issue with Script Editor 1.x, which tended to hog the CPU rather more than it should have done, but my understanding is that this was supposed to have been fixed in SE 2. So a performance drop of this magnitude is kinda hard to figure.
While I can’t give specific advice about Illustrator, it’s sometimes worth playing around with a few variations in terms of which app is frontmost. (FileMaker Pro, for example, used to perform very much faster when run in the background, while other apps generally prefer to be frontmost. Occasionally, pushing the applet up front can produce better results.) Screen redrawing can also cause significant delays in certain situations, so setting the visible property of an app/document to false, minimising or reducing the size of a window - or switching to a simpler layout might improve performance substantially. (Microsoft Excel even has a dedicated ‘screen updating’ property, which can be set to true or false, depending on whether the current priority is user feedback or speed of execution.) Some applications are also capable of running AppleScript code internally - which can also help to give a performance boost. (Is it worth trying to run the script, or part of it, from Illustrator’s Script Menu?)
No doubt you’ve already gone through the script to see if there are any other optimisation techniques worth trying. However I’ll mention one or two that spring to mind, just in case there’s a chance of exploring/applying any…
Wherever possible, I try to identify where the major bottlenecks occur in a script - and then see if I can come up with possible remedies. Each external command sent to an application, scripting addition or the shell has a minimum cost, so it can pay to find ways of bunching such operations. It’s also worth looking closely at any repeat loops, in which a script might spend some considerable time. Are there any operations within a loop that could be executed outside it, for example? If looping through very long lists, consider using references to them, or referring to them as script object properties, instead. Another trick is to check if there are any parts of complex calculations, concatenations, etc. that could be performed in advance - and possibly stored as script properties. Even string comparisons (where case is not an issue) can be executed in about half the time, within a ‘considering case’ statement.
OK, so none of this answers the question of why there should be such a huge performance gap in the first place. But by shooting from the hip like this, I’m hoping it might just be possible to reduce the impact of that gap in some way. If you want to go into any of this in more detail, just holler…
Anyway - delighted to hear the property-passing script did the trick.