02-22-2016 03:59 PM
Hi,
I have written a labview vi to help me analyze some rather large data sets. The vi works however its very laggy and uses a lot of memory. Was hoping an expert could take a look at my code and give me some ideas on how I can modifying it to improve the speed of which it runs. I have attached my labview vi. Hopefully someone can help.
Kind regards, R
Solved! Go to Solution.
02-22-2016 04:22 PM - last edited on 12-13-2024 01:46 PM by Content Cleaner
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-22-2016 04:27 PM - last edited on 12-13-2024 01:45 PM by Content Cleaner
Things I see wrong.
1. You are constantly re-reading the same files in a loop. Do you expecting the files to change? Files should be read before the loop, and data manipulated inside the loop. I think this is your primary problem.
2. Abuse of local variables. You have numerous copies of AllRows for instance. You should have a single wire coming out of the Read from Spreadsheet file to your terminal, and branch that to wherever you need it. Many other controls are duplicated with local variables unnecessarily.
3. Lot of dupliated code. You are doing the same operations on numerous graphs. You can probably simplified by putting that into a subVI and replicate the subVI. You can probably wrap all of that up in a For Loop.
4. Your cursor property nodes seem backwards. You are readling the current X position before you set the Active Cursor. That and a race condition with the other property node in parallel means you don't know which X value you read corresponds to which cursor. Read both cursors in one node and in the proper order like this:
5. Other things as well that might become more obvious once the big items above are taken care of.
I would recommend looking at the online LabVIEW tutorials
https://learn.ni.com/learn/article/labview-tutorial
02-22-2016 04:59 PM - edited 02-22-2016 05:00 PM
Basically all of your local variables are unnecessary. I deleted your "all rows" variables and got rid of all your duplicated property nodes for the cursors and it looks like this. There's plenty left to fix, but this is a good functional improvement. You need to go through and set up some subVIs. You have a lot of duplicated code still.
This is a Snippet! Drag it to your LabVIEW block diagram to import the code directly.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
02-25-2016 05:14 PM
Thanks so much for the advice and for bearing with my weak labview skills. I was able to make most of the changes recomended and the VI is working much better. I will review the tutorial you recommended as soon as I get some time.
02-25-2016 06:59 PM - edited 02-25-2016 07:00 PM
@rkl685 wrote:Thanks so much for the advice and for bearing with my weak labview skills. I was able to make most of the changes recomended and the VI is working much better. I will review the tutorial you recommended as soon as I get some time.
FYI - no time like the present. The sooner you can start producing quality code, the better. 🙂
Sorry, those were supposed to be words of encouragement, but somehow it seems a lot harsher than I had intended.