|
Prev: Equivalent of "C static local" variable?
Next: NI PCI-1588 Windows XP Accurate Timing Device
From: Norbert B on 6 May 2008 11:10 Altenbach, you are, in general, correct about the performance issues. I just made a small benchmark with my solution and dave's. dave's is about 6 times faster than mine.But now there is one thing i am wondering:My solution depends on the actual "length" of the number; the higher the value, the longer the vi takes for 1,000,000 iterations. The time does increase about 10% (950 ms up to about 1100). BUT: It does not have to much impact how many bits i mask.dave's solution does only mask one bit at an iteration, so i think, if masking more bits, the time used to solve this will increase in reference to the number of bits. A single bitmask took (for 1,000,000 iterations) 170 ms on my machine. So if the increase for "bits to mask" is additive, my solution would be equal to dave's @ about 6 bits.So, just wondering: is my thinking correct? If it is, is there a more elegant way to solve this?Please note that the screenshots in the link to the bit twiddling challenge do not enlarge on my system... (i use firefox, but it does not work in IE either.....)Norbert
From: daveTW on 6 May 2008 12:10 Hi Norbert,this is my update...<img src="http://forums.ni.com/attachments/ni/170/321445/1/set%20bit%20in%20U32%20w%20mask.png"> greets, DaveMessage Edited by daveTW on 05-06-2008 05:54 PM set bit in U32 w mask.png: http://forums.ni.com/attachments/ni/170/321445/1/set bit in U32 w mask.png set bit in U32 w mask.vi: http://forums.ni.com/attachments/ni/170/321445/2/set bit in U32 w mask.vi
From: parthabe on 7 May 2008 00:40
MikeS81 wrote: Nice solution Norbert, but what�s that? :smileyhappy: <img src="http://forums.ni.com/attachments/ni/170/321296/1/Numbermasking.PNG"></a> MikeMessage Edited by MikeS81 on 05-06-2008 11:21 AM Mike, That's Norbert's version of <a href="http://forums.ni.com/ni/board/message?board.id=BreakPoint&thread.id=2634" target="_blank">Rube</a> Goldberg Code. :smileyvery-happy: |