Ramda _concat perf improvement

Benchmark created on


Setup

function _current(set1, set2) {
  set1 = set1 || [];
  set2 = set2 || [];
  var idx;
  var len1 = set1.length;
  var len2 = set2.length;
  var result = [];

  idx = 0;
  while (idx < len1) {
    result[result.length] = set1[idx];
    idx += 1;
  }
  idx = 0;
  while (idx < len2) {
    result[result.length] = set2[idx];
    idx += 1;
  }
  return result;
}

function _next(set1, set2) {
  set1 = set1 || [];
  set2 = set2 || [];
  var idx;
  var len1 = set1.length;
  var len2 = set2.length;
  var result = Array(len1 + len2);

  idx = 0;
  while (idx < len1) {
    result[idx] = set1[idx];
    idx += 1;
  }
  idx = 0;
  while (idx < len2) {
    result[len2 + idx] = set2[idx];
    idx += 1;
  }
  return result;
}

var arr = [];
for (var i = 0; i < 1000; i++) {
  var inner = [];
  for (var j = 0; j < 10; j++) {
    inner[j] = j;
  }
  arr[i] = inner;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Current
_current(arr, arr);
ready
Next
_next(arr, arr);
ready
Native
arr.concat(arr);
ready

Revisions

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