LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code executes much slower than I think it should.

Running LabVIEW 2010 on a newer W7 machine.  The attached code seems to run dog slow and I'm wondering if anyone can give pointers on how to speed it up?

Thanks.

 

0 Kudos
Message 1 of 11
(3,358 Views)

Hi Rick,

 

all I did was to replace your "Array" local variables by shift registers. Can you imagine the speed increase?

Main problem is the use of local variables of big arrays. Each time you write to the local LabVIEW has to copy data, move the copy to the actual indicator and sometimes even refresh the indicator. As you only need the result of your loop and (probably) are not interested in any intermediate steps while running you should only refresh the indicator once after the FOR loop!

 

Rename attachment from *-vi to *.vi, still trouble with attachment in the forum...

 

So now for the real thing:

check.png

This one does basically the same as your VI, but faster. All you have to do is to index the columns you need...

("Faster" means like 100s to 0.1s :D)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,352 Views)

Your other problem was that you were using Insert Into Array when you should have been using Replace Array Subset.  So instead of working on your arrays in place, you kept growing your arrays.

 

But as Gerd already state, just use the Spreadsheet String to Array function.  It has been one of my mostly used functions this last year.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 11
(3,330 Views)

Yes, changing to shift registers and fixing the Replace Array Subset did speed it up quite a bit.  Thanks.  I have a question on the Spreadsheet to Array function.  I have attached how I think it should work, and I just want to verify.  The string is made up of lines that each hold 3 floating point numbers.  I need arrays of the 2nd and 3rd number in each line.  How would the 3D array be arranged from that?

0 Kudos
Message 4 of 11
(3,313 Views)

You want a 2D array.  The format should just be "%f" and your delimiter should be "," (no quotes in the actual code).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 11
(3,307 Views)

Hi Rick,

 

you have a spreadsheet of data - or in other words you have two-dimensional data aka table aka page.

 

Where do you expect a 3rd dimension? That would be a cube (or to keep the analogy more like a stack of pages)...

 

So simply follow my snippet above!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(3,304 Views)

@rickford66 wrote:

 I need arrays of the 2nd and 3rd number in each line.  How would the 3D array be arranged from that?


As others have said, you code is pure gibberish. Use the suggested code mentioned earlier. To get the second and third column from the 2D array, use index array and wire a 1 to the lower index. Leave the upper index unwired. This will give the second column. Now resize index array downward for two outputs and you get the third column there. 

0 Kudos
Message 7 of 11
(3,296 Views)

Of course, what was I thinking.  I think I had a brain fart.  haha   Yes, I want a 2D array.  Thanks.

0 Kudos
Message 8 of 11
(3,289 Views)

BTW Crossrulz, I cannot open your vi because it's saved as a later version of LV.  I'm using 2010.  Thanks.

0 Kudos
Message 9 of 11
(3,287 Views)

@rickford66 wrote:

BTW Crossrulz, I cannot open your vi because it's saved as a later version of LV.  I'm using 2010.  Thanks.


I just saved it in 2009.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 11
(3,259 Views)