array push vs compose (ramda)

Benchmark created by andyd on


Preparation HTML

<script src="https://raw.githack.com/CrossEye/ramda/master/ramda.js"></script>

Setup

var articles = [
      {
        title: 'Everything Sucks',
        url: 'http://do.wn/sucks.html',
        author: {
          name: 'Debbie Downer',
          email: 'debbie@do.wn'
        }
      },
      {
        title: 'If You Please',
        url: 'http://www.geocities.com/milq',
        author: {
          name: 'Caspar Milquetoast',
          email: 'hello@me.com'
        }
      }
    ];
    
    var _ = ramda;

Test runner

Ready to run.

Testing in
TestOps/sec
array.push
var names = function(d) {
 var data = [];
 for (var i=0;i<d.length;i++) {
      data.push(d[i].author.name);
 }
 return data;
}

console.log("test1", names(articles));
ready
compose (ramba)
var names = _.map(_.compose(_.get('name'), _.get('author')))


console.log("test2", names(articles));
ready

Revisions

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

  • Revision 1: published by andyd on