I've done some more changes and hidden most of the code in a sub-vi. I've also shown how to make the code scalable, in case you suddenly need to accomodate 7 or 10 inputs.
In the new VI's, I've shown 2 different approaches to your code, but both are functionally equivalent.
As far as performance, you can always gain a little boost by going to File --> VI Properties --> "Execution" and deselect "Allow Debuging".
There might be other ways to optimize your code, but the thing you need to ask yourself is if this is really necessary.
If you go to File --> VI Properties --> Memory
you will see some "stats" for your current VI.
The one you posted originally, has a memory footprint of ~117.5k... as for cpu-usage, unless you are working with a significantly bigger project, you do not need to worry about performance at all, unless you are on a very very old computer.
That said, optimizing code is always important, and it is a very good way to learn, but sometimes one must be able to see when "enough is enough" and something is "good enough".
🙂For comparision, the new VI I made for you, which includes 2 examples/different ways of doing it, takes only ~56.7k... though I'm not sure if you need to add the sub_vi to this or if it is already added.. the sub-vi is ~23.7k total..
Hope this helps you, and if someone else can take a look to see if there is any other obvious ways to optimize the code, then both me and the thread-owner will learn something more here.
🙂
---------------------------------------------------
Project Engineer
LabVIEW 2009
Run LabVIEW on WinXP and Vista system.
Used LabVIEW since May 2005
Certifications: CLD and CPI certified
Currently employed.