LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I remove repeated elements in an array

@: altenbach : beautiful piece of code, very interrestingpouce_levé.gif

0 Kudos
Message 21 of 38
(2,275 Views)

Now this worked.........

I added my new method ( which you were reffering , i am getting close ) in benchmark                        

I still wonder that my first method was very slow ( in comarison to using build array or delete from array )

is it only because of the reson you explaned ( N*N comparison ), if it so i will have to look for this in future.

 

best thing for me i almost reached upto you atleast in some solution.Smiley Very Happy

 

 new test.png

0 Kudos
Message 22 of 38
(2,269 Views)

You forgot to change the cluster size of "array to cluster". Thus you are only charting four traces max.

Message 23 of 38
(2,265 Views)

@altenbach wrote:

You forgot to change the cluster size of "array to cluster". Thus you are only charting four traces max.


Yes , you are right and when I changed the cluster size , I can see some spikes ( going upto 2 ms ) in my method sometimes, don't know why?

0 Kudos
Message 24 of 38
(2,240 Views)

@Neos wrote:

Yes , you are right and when I changed the cluster size , I can see some spikes ( going upto 2 ms ) in my method sometimes, don't know why?

Curiously, I see spikes in ouadji's method mostly (red trace). However, If I only run this method (select same in all elements of the code array), I no longer see it. I also don't see if for smaller sizes (e.g. 1000). It is possible that maybe the OS is randomly doing something else for a moment. Hard to tell. Maybe a cache miss?

 

I would ignore these spikes.

 

 

 

0 Kudos
Message 25 of 38
(2,225 Views)

altenbach's method  slightly improved, slightly faster (altenbach_2)

 

SR1.png     SR2.png

 

SR3.png

Message 26 of 38
(2,199 Views)

@ouadji wrote:

altenbach's method  slightly improved, slightly faster (altenbach_2)


Cute.


I suspect that reading two adjacent elements in an array can take advatange of SSE. I would not have expected it to be faster because you are now actually getting (indexing) each element twice. I guess the compiler can sort things out well here. The very small performance difference might be strongly LabVIEW version specific or migh even invert after a recompile of the code.

0 Kudos
Message 27 of 38
(2,187 Views)

@altenbach wrote:

Mine is pretty standard code and I suspect that the openG version is similar (not checked, because I don't have it). 


Since it sounds like you don't use OpenG much (ever?) I'll let you in on a little secret.  Generally OpenG code is not the most efficient way of doing things.  Many of the Array functions were written in the 5.x and 6.x era and what worked well then isn't always the same as today.  OpenG also seems to favor functionality, and reuse over performance.

 

Given your talents at improving LabVIEW code performance, I suspect that OpenG could benefit immensely if you were able to re-write some of their functions.  

 

But as a comparision I tried the OpenG method and it was about 7 times slower however the OpenG method also returns the indicies of removed elements as an output.  After removing this the speed didn't change much.

0 Kudos
Message 28 of 38
(2,164 Views)

Yes, that openG version looks slow!

 

(What is the reasoning of providing the indices of the removed elements. Wouldn't it be equally interesting to show the indices of retained elements? ;))

 

 

I am pretty confident that I could modify my version by spending a few minutes to also give the order so the output can be sorted in "first seen order". Maybe 2x slower? Maybe I try next weekend.... anyone want to try too?

0 Kudos
Message 29 of 38
(2,148 Views)

@altenbach wrote:

Yes, that openG version looks slow!

 

(What is the reasoning of providing the indices of the removed elements. Wouldn't it be equally interesting to show the indices of retained elements? ;))

 


Like I said it was 7 times slower which was still better then most of the other ones posted here but not all.

 

Providing indicies of removed, or indicies of retained are equally important I guess since you can get one from the other.  Still I have used that output before.  Say I remove duplicates from one array, and have a second array that is of some other data type that I also want to have the same change applied.  I can then use the Delete Element From Array (OpenG again) which accepts an array of indicies to remove.

0 Kudos
Message 30 of 38
(2,140 Views)