08-22-2023 01:39 AM
Hello LabVIEW Community,
i am new to the LabVIEW Topic but i had to make a LabVIEW program which is a little bigger. Now i already got rid of blocks like DAQ Assistents and everything but my program still takes much too long to run through one loop. I wanted to ask if anybody knows why. My suggestion is that this application has to be buildt (exportet as .exe) to be faster, because in labview the code is compiled every time. Can this be a reason?
So has anyone recommandations about how to make the programm faster. (3 seconds is much too long)
08-22-2023 02:29 AM - edited 08-22-2023 02:31 AM
No, the problem is not in the LabVIEW environment, because when you start running, all the code is already compiled.
As many (if not all) newbies, you tend to make things more complicated than needed. Just as an example, you don't need to extract the number of rows of the initial 2D text array eleven times; do it just one time then wire the result to the code needing this value: a wire can be branched to multiple destinations! Likewise, you are extracting the very same portion of the 2D array multiple times.
However, this is not the reason your code is slow, rather it more refers to readability and maintainability of the code.
To make the code faster, start with doing your hardware initializations (create channel, start task and alike) before the loop and doing cleanup (stop and clear task) after the loop is finished, taking care to open a given channel only one time and then branching the wire to all places where it's needed.
(There are more remarks to do about this code, but I have little time to analyze it in detail).