Map - While vs Lodash (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.backbone.js"></script>

Setup

var src = [], dst = [];
    
    function square(i) { return i * i; }
    
    for (var i = 0; i < 1e5; i++) {
      src.push(square(i));
    }

Test runner

Ready to run.

Testing in
TestOps/sec
While loop
var  index = -1, length = src.length;
while(++index < length) { dst[index] = square(src[index]); }
ready
Lodash map
dst = _.map(src, function(i){ return square(i); });
ready

Revisions

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