fooloop

JavaScript performance comparison

Test case created by Carl Lumma

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var big = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22];
  
  var powerSet1 = function(arr) {
    var result = [[]];
    for (var i=0; i < arr.length; i++) {
      for (var j=0, len=result.length; j < len; j++) {
        result.push(result[j].concat(arr[i]));
      }
    }
    return result;
  }
  var powerSet2 = arr =>
  	arr.reduce((sets, v) =>
  		(sets.concat(sets.map(set => set.concat(v)))), [[]]);
  

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
loopy
powerSet1(big);
pending…
straight
powerSet2(big);
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments