Square Root Example


This example is designed to give an idea on how performance can scale using Hamsters.js, you can play around with different test sizes to see how scaling changes with problem size. Originally created specifically for development purposes, now available as a public example demonstrating the dynamic, concurrent, and stateless-ness nature of the Hamsters.js software package.

This is what would be considered an embarrassingly parallel problem, the provided example will generate an array containing the selected test size amount of randomly generated integers. After the random array is generated the benchmark will then loop through the data set multiple times, calculating the square root of every integer, each iteration increasing the number of threads used up until reaching the number of logical threads detected.

Once the benchmark is complete, it should render two graphs showing the relative performance change with the addition of each thread. Depending on the browser & hardware used you may see an increase in relative performance with a larger test size.


                    
                      const params = {
                        array: Array.apply(null, {length: 100}).map(Function.call, Math.random),
                        dataType: 'Float64'
                      };
                      hamsters.run(params, function() {
                        for (var i = 0; i < params.array.length; i++) {
                          rtn.data.push(Math.sqrt(params.array[i]));
                        }
                      }, function(results) {
                        console.info(results);
                      }, function(error) {
                        console.error(error);
                      });
                    
                

Client Summary

  • Hamsters.js Version:
  • Maximum Threads:
  • Browser:
  • Legacy Mode:
  • Atomic Operations Support:
  • Transferable Object Support:

Test Size



Execution Time - Lower is better

Thread Scaling % Improvement - Higher is better