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.
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:
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.
I’ve been using the approach suggested by gluebyte, and this has returned consistent results regardless of how the shortcut was run. On macOS Tahoe RC1, the returned results are ten times what I would expect when the shortcut is run by way of the Shortcut editor.
A workaround is to run the shortcut by way of Spotlight Search, and the Shortcut editor can be opened or not. Run that way, the above shortcut returned about 0.005 second.