Thanks Shane. We have enough people running scripts frequently enough that the time differences here actually do matter. We have scripts that might check the existence of a file 6 times, that are run by 25 people each 40 times a day. So that’s ≈ 6,000 runs per day, where even if it’s only saving .06 seconds, that’s collectively saving people 6 minutes a day.
I just tested these, and on first run, my script run times in Script Debugger were:
ASObjC: 0.56 s
Shell: 0.07 s
System Events: 0.03 s
Finder: 0.01 s
I tried them all again, and found a lot of variation.
Run 2:
ASObjC: 0.00 s
Shell: 0.06 s
System Events: 0.73 s
Finder: 0.00 s
So the time for System Events and ASObjC are all over the place.
I ran System Events 10 more times:
0.04
0.03
0.03
0.02
0.02
0.02
0.02
0.02
0.02
0.02
And ran ASObjC 10 more times and it was 0.00 every time.
Does something have to be initialized with ASObjC? It was only the first run that was many times slower. I tried changing file paths for the test in case it was caching something, but runs with new paths were still 0.00
With System Events it wasn’t even the first run that was the slow one, so no idea what’s going on there.
I put them each inside a repeat 1000 times loop and got:
ASObjC: 0.19 s
Shell: 49.52 s
System Events: 22.16 s
Finder: 2.53 s
Based on these results, I think I’ll just stick with Finder. It was consistently super fast, and I’m familiar with it. Based on the results of the 1000x repeat, ASObjC is way faster - but by “way faster,” I mean it’s 0.00234 seconds faster. It would collectively save everybody 14 seconds per day, assuming we never get any repeats of my initial .56s run.
As you know from helping me in the past, I’ll certainly use ASObjC when it’s the only way to get the job done. But 4 people work on this code base, and none of us know ASObjC, so there’s a strong preference for avoiding it when it’s not necessary until at least a couple of us take the time to learn it. I suppose on the flip side, if we started using it whenever possible that would help us learn it… but that’s a scary approach to learning for code that’s in production.