Shortcut Execution Speed

I occasionally need to check the execution speed of all or a portion of a shortcut, and I’ve always used the Stopwatch action for this purpose. It’s only accurate to a hundredth of a second, but that’s fine for a shortcut.

It turns out there is a simpler and more accurate approach, which is to use Set Variable actions with the value set to Current Date and the date format to A, which is the elapsed milliseconds in the current day. This approach has an overhead of about 5 milliseconds, but, once again, that’s fine for testing a shortcut.

Two Date actions and a Calculate action may be a simpler solution:

1 Like

Gluebyte. Thanks for the suggestion, which is simpler and returns similar results, and is the approach I will use. The only substantive difference is that one approach returns milliseconds:

and the other returns seconds:

BTW, using your approach, the timing result on my M2 Mac mini with no action at all is reliably in the range of 4 to 5 milliseconds. The timing result shown in your screenshot with no action at all is a bit under 2 milliseconds. A few milliseconds is not significant in actual use, but I wonder why the difference.

First few actions in a shortcut seem to run slower than the rest. I had a few more actions prior to the first Date action in the screenshot.

You can try this one for yourself: https://www.icloud.com/shortcuts/13fe145b99ad46e68099b7a63c9ca234

1 Like

Thanks gluebyte–that explains things. My results with your shortcut FWIW.

1 Like