9 seconds to execute simple AppleScript

I have a macOS application (10.15.4 Xcode 11.4.1) that has all the necessary entitlements to execute AppleScript against 'Contacts'.


The script works correctly but I am experiencing a 9 second interval to execute this trivial script:

tell application "Contacts" to return the id of the first person whose selected is true


I have experimented with executing this as a compiled script or as [[[NSAppleScript alloc] initWithSource:@"..."];


I see the same time interval either way.


So two questions:


1) Why would the time be the same if it had already been compiled?


2) Why on earth does it take that long to execute?


Any thoughts appreciated!

Answered by SwampDog in 418841022

A dramatic improvement:

tell application "Contacts"
  set thisList to selection
  return id of first item of thisList
end tell
Accepted Answer

A dramatic improvement:

tell application "Contacts"
  set thisList to selection
  return id of first item of thisList
end tell
9 seconds to execute simple AppleScript
 
 
Q