LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build array efficiency

Solved!
Go to solution

Hello,

 

I would like to know, wheather my solution is efficient, or it can be done in a better way.

I have a mass spectrometer with a shipped labview driver and example VIs.

I want to modify one of the VI. Here the used structure of the spectrum is a kind of waveform cluster. I have attached a non funcional only-test VI, to show it. For data evaluation, I need to use XY-data pairs, so I need to create X,Y arrays from this cluster type. The size of the arrays are in the order of 10 thousends... Just in case, I will use a queue wire to do the data evaluation (consumer loop) independent of the producer loop (about 0.5 Hz data production, so every 2 sec I get a new spectrum from the MS driver).

 

So my question is that, is there a better way to create the XY arrays from that cluster type? Depending on the data size, in my experiance, this can be a bit slow...?

Thanks for advice!

 

dropbox link: (the discussion forum is not able to upload my VI... 😞 )

https://dl.dropboxusercontent.com/u/8148153/test1.vi

0 Kudos
Message 1 of 11
(4,040 Views)

There is slight room for improvement according to me.

xy.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 2 of 11
(4,009 Views)
Solution
Accepted by topic author Blokk

In LV 2013 I think the solution proposed would be OK but in earlier versions you're always better off allocating the full array to begin with and replace instead of using the autoindexing of a for-loop.  The reason for the LabVIEW version dependence is that exactly this operation has been greatly optimised by the compiler in LV 2013.

 

Shane

Message 3 of 11
(4,001 Views)

Recently I have LV2013 for the project, so I guess I just keep it as it is.

But thanks for the info, I will keep in mind this difference when I have to deal with pre-2013 systems...

regards,

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

And to quote Altenbach before he writes it, the loop can be replaced with a Ramp-function. 🙂

(Whether that preallocates the array i dont know)

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 11
(3,990 Views)

could you show an example? I do not know this "ramp function"...

0 Kudos
Message 6 of 11
(3,988 Views)

See attached snippet.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 11
(3,978 Views)

thanks! it is also useful 🙂

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

I agree with the ramp function being a bit more efficient, but I am not sure about replacing array subset for building sequential numbers. I would be interested to learn if it was otherwise.

The following post seems (I agree is old) seems to back up my understanding. I also did a quick benchmark and it seems to back my belief

http://forums.ni.com/t5/LabVIEW/create-an-array-of-consecutive-integers/td-p/127751


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 9 of 11
(3,968 Views)

I need to make a quick correction to my earlier post:

 

I was thinking of conditional indexing when I mentioned the difference between LV Versions.  This kind of unconditional indexing has been pretty efficient for some time now.  I wouldn't bother replacing it with a ramp VI.  I would just leave it as it is to be honest.  It's clear for any programmer what's going on.

 

Shane.

Message 10 of 11
(3,952 Views)