Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Linux
Desktop
6 years ago
Test name Executions per second
Lodash 957.0 Ops/sec
Ramda without relying on currying or composition 637.5 Ops/sec
Ramda with currying and composition 594.3 Ops/sec
Underscore 874.2 Ops/sec
HTML Preparation code:
x
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.js"></script>
2
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
3
<script type="text/javascript">
4
  window.lodash = _;
5
  _ = null;
6
</script>
7
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.0/underscore.js"></script>
8
Script Preparation code:
 
  var data = _.range(10000).map(function(i) {
    return {
      counter: i
    }
  });
  
  function isOdd(num) {
    return num % 2 === 1;
  }
  
  function square(num) {
    return num * num;
  }
  
  function lessThanThreeDigits(num) {
    return num.toString().length < 3;
  }
Tests:
  • Lodash

     
    var result = lodash.chain(data)
      .map(item => item.counter)
      .filter(isOdd)
      .map(square)
      .filter(lessThanThreeDigits)
      .value();
  • Ramda without relying on currying or composition

     
    var result = R.filter(lessThanThreeDigits,
      R.map(square,
        R.filter(isOdd,
          R.pluck('counter', data))));
  • Ramda with currying and composition

     
    var result = R.pipe(
      R.pluck('counter'),
      R.filter(isOdd),
      R.map(square),
      R.filter(lessThanThreeDigits)
    )(data);
  • Underscore

     
    var result = _.chain(data)
      .map(item => item.counter)
      .filter(isOdd)
      .map(square)
      .filter(lessThanThreeDigits)
      .value();