Reading menu conditions get real slow as CPU is busy

It sounds real obvious. Of course actions get slower as the cpu is busy with a program. But i'l ask anyway, because i think it is still a bit too much in my opinion.

I am a Pro Tools users. I use a lot KM actions, some for fairly basic operations. Some rely on reading what the actual menu status is. So i implement an If Then Else, where the "If" is a menu condition like this

I have noticed that on large sessions the time before this action finishes can take up to 5 seconds. I have made a super large session that just plays on my machine and then it even takes 10 seconds for this macro to finish. If i leave out the IfThenElse it is instantly. So it appears that this reading of the menu state is the culprit.

Anything i or you can do about this?

1 Like

Hey @Fokke,

Yes – you can give the condition a specific path – so KM doesn't have to spend time searching the menu structure.

Try the macro in the Keyboard Maestro Editor.

-Chris


Test Menu-Path Condition.kmmacros (5.6 KB)

1 Like

Ah thanks, good to know. So you give KM a hint where to look.

I tried it; but it doesn't help much. It inserted a Stopwatch action (found on the forum here)

These are some times i logged. This is a very heavy loaded session and even the graphics slows down, but therefore makes it a good test case.

Without Path:
Link Timeline and Edit Selection

13.719
12.436
8.661
7.384
7.127

With Path:
Options > Link Timeline and Edit Selection

4.996
19.818
33.260
4.923
5.633
5.972
19.883

See that it once even took 33 seconds before the macro completes.

If the system is that bogged down there's probably nothing to be done.

Although you could try AppleScript and UI-Scripting just to see if it responds the same way.

-Chris

I bog the system just to make the differences clear.
These are the times with a moderate session with moderate CPU load.
(seconds.ms)

3.129
2.607
2.334
1.518
2.043
2.813
3.661
2.513
1.829
1.210

Still too long imho.
Thanks for your suggestion with the path, it will help a little i guess. But it seems are is another culprit.

Update;

I forgot to change

with this name

to
with path

Now i get this times with the 'moderate session'.

0.198
0.205
0.206
0.226
0.188
0.198
0.241
0.208

Thats a whole lot better! Thanks a lot for the tip Chris!

1 Like

Yes - accessing menus in general means scanning through all the menu bar, then all the menus in each, then all the submenus. And each one requires inter-application communication which is slow to say the least. On top of that, some applications have very slow menus, probably because they dynamically generate them, so they are probably re-generating them each time Keyboard Maestro asks for the next piece.

Menu Paths will be much more efficient in such cases.