The Cocoa app has a compiled AppleScript which I call into for the
various handlers with the parameters I need.
This is working well in every other case.
[snip]
However I have a case where it is taking 25 seconds to execute a
single AppleScript statement!
This same statement has sub-second response when executed in the
Script editor.
If I simulate the Cocoa calls with various handlers in the Script
Editor everything is fine - performance is fine!
Have you tried using Shark to see exactly what your machine is doing
during those 25 seconds? It might be enlightening.