Array Combo Check

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var myData = [1, 201, 100];
  
  var combo1 = [1, 100, 200];
  var combo2 = [1, 101, 201];
  var combo3 = [1, 100, 201];
  var combo4 = [1, 101, 200];
  
  var combos = [combo1, combo2, combo3, combo4];

};
</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
Method A
return combos.some(function(combo) {
    return combo.every((item) => myData.includes(item));
});
pending…
Method B
var res = combos.filter(combo =>  combo.every(n => myData.some(curr => curr === n)));
pending…
Method C
var res = combos.findIndex(combo =>  combo.every(n => myData.some(curr => curr === n)));
pending…

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

0 Comments