EnterpriseQualityCoding / FizzBuzzEnterpriseEdition

FizzBuzz Enterprise Edition is a no-nonsense implementation of FizzBuzz made by serious businessmen for serious business purposes.
21.23k stars 749 forks source link

Efficiency Issues #174

Open hacatu opened 9 years ago

hacatu commented 9 years ago

I believe that this program is very inefficient. It should be taking advantage of multithreading so that the value to print for each number can be computed in a different thread. To avoid the threads printing in the wrong order, I recommend creating a mutex singleton which can be owned by a thread. Initially it is owned by thread 0 and then thread zero releases it. Every other thread, when finished and ready to print, performs blocking checks of the last owner property of the mutex singleton. If the last owner was the thread one less than the thread making the check, it acquires the mutex, prints its value, and then releases the mutex. This solution should be more performant and scaleable than your current solution. To improve upon it further, I would recommend that you use servers in vms for each thread. The servers should communicate by emailing each other. This way each server's actions may easily be monitored. Also, because addition is faster than multiplication, you should implement multiplication, division, and modulus using repeated addition and subtraction. These in turn should be replaced by repeated incrementation and decrementation. To avoid integer roundoff, I would recommend using a rational number class, but remember to normalize it after every operation by dividing the top and bottom by their gcd. Please implement these features: I need to use this code in a real world enterprise project.

vendethiel commented 9 years ago

Aaaand you got me to spit my drink at "communicate by email".

Dmitry-Me commented 9 years ago

No, email is poorly standardized. Fax is much better.

kenchangh commented 9 years ago

Never go full retard.

dimitarg commented 9 years ago

I love github :)