LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Prime Factor Coding Challenge

Looks pretty interesting, but on my rig it is slightly slower than a VI modified from my code above. (mine: 3.9s, yours 4.2s). The results for 8 digit limit is the same. Interestingly, if you use constants instead of controls for the inputs, LabVIEW folds the entire code into a constant and the compile now takes about 4 seconds. After that, it always executes in 0ms!! 😄
 
Here's a display showing the constant folding. 😮
 

Message Edited by altenbach on 01-24-2007 02:01 PM

Message 181 of 186
(1,676 Views)

Hmmm, on my system the comparison is yours: 4.1s, mine: 1.9s.  What kind of system are you on?  The speed of my code is strongly dependant on the blocksize, which needs to be tailored to fit your system's processor (cache size).  I'm also using Labview 8.2.  Maybe the compiler got smarter about how it allocates/handles arrays between versions...

thanks for the feedback,

- ben.

0 Kudos
Message 182 of 186
(1,661 Views)
No, clearly your times are very impressive, especially since you throw so much smart more code at it. 😉 I agree that this will strongly depend on the CPU architecture.
 
Actually, I just noticed that I was running on batteries. Your code wins once I am plugged in (mine: 2.9s, yours: 1.9s), go figure.... 😮
 
Anyway, I am running on an Intel Core2 Duo Mobile 7600 at 2.33MHz, 1.5GB RAM.
 
 
(Now we just need to do some code modifications that it can utilize both CPU cores efficiently. ;))
 
 
Message 183 of 186
(1,651 Views)
Hi, I must lost zero but to not carry out successful.. 😕

            

0 Kudos
Message 184 of 186
(1,376 Views)


bluebeard wrote:
Hi, I must lost zero but to not carry out successful.. 😕 

If you want to remove zeroes from a 1D array, you could do something like in the this VI.
 
Message 185 of 186
(1,352 Views)
Or, use a separate counter to keep track of the count of primes you've found so far, and use that to add them to the output array with no gaps of zeros.  Then reshape array at the end to cut off all the trailing zeros. 
Message 186 of 186
(1,328 Views)