From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary Parsing - Which method is faster - CHALLENGE


@DailyDose wrote:
But this will produce 8 boolean, yes?  Which later you must then dig out only the 6.

"Number to boolean array" will also produce 8 booleans for an U8 input. Just because you don't index them out is irrelevant. The cluster size is set to six, so that's fine.

Message 11 of 15
(503 Views)

@BertMcMahan wrote:

Pre-generating a lookup table array seems to beat Solution B (as-posted) by about 2x:

 

BertMcMahan_0-1685032621478.png

.


Careful there! If you use a 6 bit LUT, the index needs to be masked to 6 bits because in the current example the indices can be any 8 bit value.

 

altenbach_0-1685035836131.png

 

Of course in the real application this might not be needed, assuming the number is guaranteed not to exceed 6 bits (0..63).

 

Note that the LUT generation is "constant folded", i.e. replaced by an array constant in the compiled code)

 

Message 12 of 15
(483 Views)

@mcduff wrote:

@DailyDose wrote:


But this will produce 8 boolean, yes?  Which later you must then dig out only the 6.


Don't understand the question. Your VI used only 6 booleans, if you want all 8 right click and change the array to cluster size. (This picks out the first 6 booleans in the array.) The main limitation is that you can't specify just the middle booleans, only from beginning to end.


No, that's my bad.  I.... A) Didn't know you could do that.  And B) Didn't see the comment.  My apologies.

0 Kudos
Message 13 of 15
(471 Views)

Looks like the LUT method is leading by a significant margin (and I'm even giving the LUT a handicap by building it each time).  Props to @MertMcMahan and @altenbach

 

DailyDose_0-1685038915383.png

 

0 Kudos
Message 14 of 15
(443 Views)

@DailyDose wrote:

(and I'm even giving the LUT a handicap by building it each time).


Make sure you turn off debugging and the LUT generation will be constant folded, i.e calculated once at compile time.. No penalty.

0 Kudos
Message 15 of 15
(420 Views)