BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code


@altenbach wrote:

@altenbach wrote:
In a few tens of seconds it solves 1G where the result is 24739512092254535.

Finally tested on a modern I7 and it finds and adds all primes below 1'000'000'000 (1G) in well under 10 seconds. 😄


Some speed tests here, I'm pretty impressed at how fast that code runs.

 

10=375.23us sum=17

100=7.85us sum=1060

1 000=15.09us sum=76127

10 000=30.79us sum=5736396

100 000=272.89us sum=454396537

1 000 000=2.80ms sum=37550402023   (finally took longer than 1ms)

10 000 000=28.73ms sum=3203324994356

100 000 000=495.18ms sum=279209790387276

1 000 000 000=5.99s sum= 24739512092254535 (longer than 1s)

1 500 000 000=9.01s

1 600 000 000=9.44s

1 690 000 000=10.09s

1 700 000 000=10.16s

1 750 000 000=10.45s

2 147 483 647=12.97s sum=109930813984377205 (longer than 10s)

0 Kudos
Message 1511 of 2,565
(10,387 Views)

@altenbach wrote:

@altenbach wrote:
In a few tens of seconds it solves 1G where the result is 24739512092254535.

Finally tested on a modern I7 and it finds and adds all primes below 1'000'000'000 (1G) in well under 10 seconds. 😄


I got between 5 and 6 seconds for my 1G run here. I'm pretty impressed at how fast your code runs. (and up to 2,147,483,647 in 13ish seconds)

0 Kudos
Message 1512 of 2,565
(10,432 Views)

There is still a little slack left. You should replace the "<0" with a "<=0" inside the small case structure.

Are you using LabVIEW 64bit? I get an "out of memory error" if I go above 1G on 32bit LabVIEW.

0 Kudos
Message 1513 of 2,565
(10,417 Views)

@altenbach wrote:

There is still a little slack left. You should replace the "<0" with a "<=0" inside the small case structure.

Are you using LabVIEW 64bit? I get an "out of memory error" if I go above 1G on 32bit LabVIEW.


Yes. LabVIEW 64bit. Good for things like this, but likes to spontaneously crash when I close it.

I'll give your tweak a shot when I get in on monday.

0 Kudos
Message 1514 of 2,565
(10,332 Views)

Time for the thread revival:

 

Saw this today... not sure what the person was thinking.

 

Capture.PNG

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

Message 1515 of 2,565
(10,194 Views)

@bsvare wrote:

Time for the thread revival:

 

Saw this today... not sure what the person was thinking.

 


Always love a thread revival.

 

That can't be what the person wants it to do.  I'm sure they intend on this being a VIG.  Still the If == True is a classic.

0 Kudos
Message 1516 of 2,565
(10,199 Views)

@bsvare wrote:

Saw this today... not sure what the person was thinking.


You should always post a link to the original thread.

 

There are many things wrong here:

  • the "equal true" of course.
  • the fact that the loop only runs once, so the shift register will never exceed 1. The value could be obtained from "boolean to 0,1" of the subVI output and eliminating the upper half of the code..
  • ...
0 Kudos
Message 1517 of 2,565
(10,192 Views)

@altenbach wrote:

@bsvare wrote:

Saw this today... not sure what the person was thinking.


You should always post a link to the original thread.

 

There are many things wrong here:

  • the "equal true" of course.
  • the fact that the loop only runs once, so the shift register will never exceed 1. The value could be obtained from "boolean to 0,1" of the subVI output and eliminating the upper half of the code..
  • ...

There's no link because there's no thread.  It was something I saw in person today.To be nice to the person who wrote it, I wasn't going to give them credit.


But the code is suppose to be an "Init once" routine.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 1518 of 2,565
(10,186 Views)

@bsvare wrote:

But the code is suppose to be an "Init once" routine.


It is called "First Call?".  See, I did it all in one node.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 1519 of 2,565
(10,175 Views)

 

(seen here)

 

Try to simplify this while loop 😄 😮

 

 

 

(It is important to know that the "array" indicator gets reset to default upstream somewhere in an earlier frame of a long flat sequence.)

Message 1520 of 2,565
(10,030 Views)