HTML Preparation code:
x
 
1
<html>
2
    <head>
3
        <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
4
        <script>
5
        underscore = _;
6
        </script>
7
8
9
        <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.12.0/lodash.min.js"></script>
10
11
        <script>
12
        lodash = _;
13
        </script>
14
    </head>
15
    <body>
16
    </body>
17
</html>
18
Script Preparation code:
 
var PromosArray = [
    {
        type: "regular",
        display: "$123.00"
    },
    {
        type: "markdown",
        display: "$100.00"
    },
    {
        type: "promo",
        display: "$80.00"
    }
];
function testArrayIteration() {
    var items = [];
    var i;
    for (i = 0; i < PromosArray.length; i++) {
        items.push(PromosArray[i].type);
    }
    return items;
  
}
function testArrayMap() {
    return PromosArray.map(function (promo) {
        return promo.type;
    });
}
function testUnderscoreMap() {
    return underscore.map(PromosArray, function (promo) {
        return promo.type;
    });
}
function testLodashMap() {
    return lodash.map(PromosArray, function (promo) {
        return promo.type;
    });
}
Tests:
  • testArrayIteration

     
    testArrayIteration();
  • testArrayMap

     
    testArrayMap();
  • testUnderscoreMap

     
    testUnderscoreMap();
  • testLodashMap

     
    testLodashMap();
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    testArrayIteration
    testArrayMap
    testUnderscoreMap
    testLodashMap

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:41.0) Gecko/20100101 Firefox/41.0
Firefox 41 on Mac OS X 10.11
View result in a separate tab
Test name Executions per second
testArrayIteration 37725312.0 Ops/sec
testArrayMap 11395883.0 Ops/sec
testUnderscoreMap 12907391.0 Ops/sec
testLodashMap 14704527.0 Ops/sec