Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just to get a little more closure on this issue by seeing how fast I could truely find these numbers, I wrote a multithreaded C++ implementation of Dr_Asik's algorithm. There are two things that are important to realize about the fact that this implementation is multithreaded.</p> <ol> <li><p>More threads does not necessarily lead to better execution times, there is a happy medium for every situation depending on the volume of numbers you want to calculate.</p></li> <li><p>If you compare the times between this version running with one thread and the original version, the only factors that could cause a difference in time are the overhead from starting the thread and variable system performance issues. Otherwise, the algorithm is the same.</p></li> </ol> <p>The code for this implementation (all credit for the algorithm goes to Dr_Asik) is <a href="http://dawnofdigital.net/script/happy_multithreaded.cpp.txt" rel="nofollow noreferrer">here</a>. Also, I wrote some speed tests with a double check for each test to help back up those 3 points.</p> <p><strong>Calculation of the first 100,000,000 happy numbers:</strong></p> <p>Original - 39.061 / 39.000 (Dr_Asik's original implementation)<br/> 1 Thread - 39.000 / 39.079<br /> 2 Threads - 19.750 / 19.890<br /> 10 Threads - 11.872 / 11.888<br /> 30 Threads - 10.764 / 10.827<br /> 50 Threads - 10.624 / 10.561 &lt;--<br /> 100 Threads - 11.060 / 11.216<br /> 500 Threads - 13.385 / 12.527<br /></p> <p>From these results it looks like our happy medium is about 50 threads, plus or minus ten or so.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload