map - lodash, ramda, .map, and ramda's internal _map

Benchmark created on


Preparation HTML

<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.29.1/ramda.min.js" integrity="sha512-PVSAmDFNqey8GMII8s9rjjkCFvUgzfsfi8FCRxQa3TkPZfdjCIUM+6eAcHIFrLfW5CTFAwAYS4pzl7FFC/KE7Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Setup

const arr = Array(10_000)
  .fill(undefined)
  .map(() => Math.floor(Math.random() * 1000));

// copy of ramda internal
function _map(fn, functor) {
  var idx = 0;
  var len = functor.length;
  var result = Array(len);
  while (idx < len) {
    result[idx] = fn(functor[idx]);
    idx += 1;
  }
  return result;
}

Test runner

Ready to run.

Testing in
TestOps/sec
lodash map
_.map(arr, x => x * Math.floor(Math.random() * 1000));
ready
ramda map
R.map(x => x * Math.floor(Math.random() * 1000), arr);
ready
array#map
arr.map(x => x * Math.floor(Math.random() * 1000));
ready
ramda _map
_map(x => x * Math.floor(Math.random() * 1000), arr);
ready

Revisions

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