LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert boolean array to an numeric count array

There must still be something funky with mine.  On the first run yours does beat mine by a considerable amount.  But the runs after are interesting where sometimes yours is faster sometimes mine is.

 

I also noticed that if the TRUE to FALSE ratio was more even yours generally did better then mine (by a few ms in a 10M size array) but if there were less transitions from TRUE to FALSE mine generally did better (again by a few ms).  I'm guessing because as I mentioned my loop doesn't run for as many elements in the array but instead runs for every transition so the fewer transitions the fewer loops on mine but yours will always be the size of the array.  I wonder if preallocating the array would have helped mine any more.  In either case this was a fun exercise, and likely beyond whatever the original poster was looking for.

0 Kudos
Message 21 of 25
(613 Views)

I did't expect to go for speed on large datasets.

 

Here is another...

The search array is suprisingly fast.

 

count_bools2.png

0 Kudos
Message 22 of 25
(605 Views)

@WillD wrote:

I did't expect to go for speed on large datasets.

 

Here is another...

The search array is suprisingly fast.


This one is almost within benchmark noise the speed of mine (in the longterm average, mine still wins by a few % on my rig) 😉

 

(OTOH, I think yours has some slack left here and there :o, maybe mine too...)

 

Search is better if there are only very few transitions, because it needs to loop less. However, even search needs to inspect every element one way or another, but it might be more optimized for SSE, for example.

 

 

0 Kudos
Message 23 of 25
(594 Views)

On my rig mine beats your previous posted one, very minimally, like ~0.4%.  I think the search is quite optimized, it smokes my bit-bashing attempt that I expected would be faster.

0 Kudos
Message 24 of 25
(589 Views)

Thanks to everybody. I have tried each program it works fine. When I run Hooovahh program I am getting some delay due to the higher input of N terminal. I reduced to 10000. Now it executes fine.

 

Regards

 

Gokul

0 Kudos
Message 25 of 25
(560 Views)