DATE: August, 2015
Example of how to use Web Workers on the browser and take advantage of parallel computing. For the sake of demonstration, a simple algorithm to compute coprime numbers is presented. Specifically, we need to find all coprime numbers from 1 to 1x10^6 such that added together sum the number of the beast (666).
To compute the coprime numbers, I use an algorithm called Euclid’s algorithm. For each number , the evaluation of is done and if it holds, such number is added to the final result.
|# Run||Sequential Time ()||Parallel Time ()|
means the runtime by executing the code using threads.
As you can see, there is a great improvement on the execution time. The parallel version works almost 5.5x times faster than the sequential version.