The two subVIs below have exactly the same code, a simple addition.
The top subVI is set with a priority of "High" and the bottom subVI with a priority of "Normal". The calling VI is set to "Normal priority". After running, High Priority time is about 20-30x larger than Normal Priority time. Any priority higher than normal except Subroutine gives the same result. Why?
I could understand if there were no benefit to make the priority higher but I am surprised that it makes the subVI runs slower.
Solved! Go to Solution.
VIs running at different priorities run in different threads (see http://digital.ni.com/public.nsf/allkb/84ECA015AA496B23862565BC006C0F19 'LabVIEW has five "execution systems", and each execution system allocates threads for four different normal priorities...The "background priority" does not normally have threads allocated for it. VIs running at this priority will use the next higher priority threads when nothing else is available to run.'). So, each call to your high-priority subVI causes a thread switch, and that's what's taking up all the extra time. If you put the entire For loop into the high-priority VI, you'll see that it executes faster than the normal-priority loop.
The lesson here is that VIs that do very little should execute in the same priority as their caller. Use differing priorities for long-running VIs, for example ones that loop repeatedly. If you need a simple function to execute as fast as possible, use subroutine priority or inline it.