LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is indexing conditional tunnel 3x faster than shift registers

Thanks for the help 🙂 Noticed some very interesting and surprising things and will be posting my observations and a new example to work with by the end of next week. It should make this exploration clearer. As you can see this is not a problem for me thus not a priority, just an exploration to get a little deeper. Would be nice to have some deeper information from inside NI 🙂

0 Kudos
Message 11 of 14
(991 Views)

@jacemdom wrote:

Thanks for the help 🙂 Noticed some very interesting and surprising things and will be posting my observations...

 

Would be nice to have some deeper information from inside NI 🙂

 


Please share those when you have time.

 

Between Greg McKaskle, Stephen Mercer and Christian, I learned a lot oabout perfromance in the LV environment. It was not mentioned above so please let me share another tidbit.

 

Watch the "Windows Task Manager >>> Performance" tab (make sure you enable View >>> Show Kernal times) to see that most of your example code is NOT dominating the CPU and a lot of time is spent in Kernal mode (i.e. allocating memory usually).

 

Take care,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 14
(986 Views)

@Ben wrote:
I seem to recall Christian indicating the "reshape" can opearte in-place. I figure I can not go TOO wrong emulating Christian

I think you are recalling wrong. Long ago the help on reshape said that it is in place, but I proved that it not always was. Many improvements occurred since, so I don't know the current status.

 

Sorry, posting by phone, will look at this thread later. In the meantime look at the videos in my signature for potential issues when benchmarking. It is a minefield!

Message 13 of 14
(979 Views)

I am a bit busy, so let's just look at the first code.

 

  • First of all, both loop should be FOR loops, because the number of iterations is known before the loop starts. The compiler might be able to make additional assumptions to optimize things (not sure).
  • Q&R is a relatively expensive function. To check for odd/even, do an bitwise AND with 1.
  • In the second loop you know the final size, so preallocate and replace is much better as mentioned by others. Always limit the number of allocations!
  • You need to disable debugging, because the additional debugging code differs between the two scenarios. For example, a case structure requires additional debugging overhead to allow probing wires in both cases.
  • To create a subarray of the even elements, I would just use "decimate array". (picture below. might need a tweak depending on if the input size is even or odd, not sure).

This does about the same with 10% of the code!:

 

 

(... and please save the ugly non-standard color scheme for the art exhibit. Such LabVIEW code is quite annoying. If you have problems with glare on the diagram, clean your glasses or have your eyes checked for cataract and such).

 

Message 14 of 14
(965 Views)