ramda xprod perf improvement

Benchmark created on


Setup

function current(a, b) {
  var idx = 0;
  var ilen = a.length;
  var j;
  var jlen = b.length;
  var result = [];
  while (idx < ilen) {
    j = 0;
    while (j < jlen) {
      result[result.length] = [a[idx], b[j]];
      j += 1;
    }
    idx += 1;
  }
  return result;
}

function next(a, b) {
  var idx = 0;
  var ilen = a.length;
  var j;
  var jlen = b.length;
  var result = Array(ilen + jlen);
  while (idx < ilen) {
    j = 0;
    while (j < jlen) {
      result[idx + j] = [a[idx], b[j]];
      j += 1;
    }
    idx += 1;
  }
  return result;
}

const arr1 = Array(1000).fill(undefined).map((_, i) => i);
const arr2 = Array(1000).fill(undefined).map((_, i) => i);

Test runner

Ready to run.

Testing in
TestOps/sec
Current
current(arr1, arr2)
ready
Next
next(arr1, arr2)
ready

Revisions

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