Any way to increase AppleScript throughput performance??
using GarageSale 8.4.1 (1326) on a M1 iMac (24-inch, M1, 2021) using macOS 12.2
This AppleScript below can only do about 2 to 3 listings per second, even when every listing’s first photo is the gallery image.
tell application "GarageSale"
set templateList to ""
repeat with aTemplate in (get selected ebay listings) -- get every ebay listing
set templateTitle to title of aTemplate
if (templateTitle is not "+++Photos:") then
if ((count of every listing image of aTemplate) > 0) then
if ((is gallery image of (first listing image of aTemplate)) is false) then
set templateList to templateList & templateTitle & ": " & (count of every listing image of aTemplate)
set loopIndex to 0
set everyListingImage to get every listing image of aTemplate
repeat with aListingImage in everyListingImage
set loopIndex to loopIndex + 1
if (is gallery image of aListingImage) then
set templateList to templateList & ", " & loopIndex
set templateList to templateList & return
display dialog "The listings with a gallery image index <> 1 are:" default answer templateList
Tried to replicate the performance issue, but it seem not enough listings in my test library have enough images to produce meaningful numbers.
While your script is executing, could you please record a “sample” file of GarageSale with Activity Monitor.
Here ya go…
I’m just using a folder with 40 listings for Sample and a folder of 80 listings for Sample 2. If I run the script a 2nd time it does take less time, I suppose since some data is already cached somewhere.
About 1/2 of the listings have 0 photos, and the other 1/2 have between 8 and 12 photos and the Gallery image is ALWAYS image #1.
You could just duplicate a bunch of the same listings to get like 80 of the same listings in a folder…
MAYBE it has to do with the fact that I have 124279 listings, with 88514 in the Trash???
Does the “repeat with aTemplate in (get selected ebay listings)” iterate all listings from the beginning every time???
Sample of GarageSale 1.txt.zip (76.6 KB)
Sample of GarageSale 2.txt.zip (74.5 KB)
The problems seems to be that AppleScript is not made for high performance applications.
From my measuring it seems that 60% of execution time is spent in Apple’s own AppleScript code, where it does god knows what, another 20% is spent is general message dispatch code, and only 10% of AppleScript execution time is spent in GarageSale’s own code.
I tweaked our code a little bit, but was only able to improve the performance of your script from 400 listings/minute to 500 listings/minute. That would still come down to > 4 hours for your 125,000 listings.
(Screenshot shows runtime at 1 minute and aTemplate at index 522).
I tinkered around a little bit and might have found a solution, albeit not an ideal one:
I added a new AppleScript that takes a ‘predicate’ string as argument, which is then evaluated against all listings within in GarageSale.
For your use case (I inverted the gallery image condition for easier testing), it takes about 7 seconds to work through the ~7000 listings in my database, which is around 100x faster than using pure AppleScript.
Together with the new ‘tag’ property on listings, you can view the results using a smart group targeting a certain tag.
The downside: GarageSale’s internal object architecture is not documented, so it’s a little tricky to compose the correct predicate string without our help.
Would that be helpful for you?
Predicate syntax resources:
WOW!!! 100x faster!!!
Hhhmmmmmm… Very Interesting…
Any way this could all be incorporated inside a single Smart Group???
Maybe an “Evaluate AppleScript” condition section?
To also be evaluated first if not empty. Not sure how error reporting would work…
And a separate “evaluation timer” Smart Group trigger condition also???
That way it could be evaluated on a periodic basis, “automatic/constantly” or “hourly, daily, weekly, monthly, etc…”???
(Maybe even an “Evaluate Now” button and also showing the last and next evaluation times??)
This Smart Group could be evaluated on it’s own thread.
You could even add a small animated icon showing when the Smart Group is “evaluating”.
And it would all be contained inside the GarageSale app.
The new “evaluate listings query” would be helpful for testing in the Script Editor app.
Simple documentation on GarageSale’s internal object architecture would be helpful.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.