loopy performances

JavaScript performance comparison

Test case created by jerryhuang3

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
for loop
var orders = [];
const [s, d] = ["_source", "doc"];


 for (let i = 0; i < 1000000; i++) {
    orders.push(
      { "_source": 
       { "doc": 
        { chargebackDate: "2019-08-27 15:14:58", 
         recurringDate: "2019-08-27 15:14:58"} 
       }
      })
 }

for (let i = 0; i < orders.length; i++) {
        let cbDate = Date.parse(
            orders[i][s][d].chargebackDate);
        let reDate = Date.parse(
            orders[i][s][d].recurringDate);
        orders[i][s][d].chargebackDate = cbDate;
        orders[i][s][d].recurringDate = reDate;
        orders[i] = orders[i][s][d];
    }
pending…
forEach
var orders = [];
const [s, d] = ["_source", "doc"];


 for (let i = 0; i < 1000000; i++) {
    orders.push(
      { "_source": 
       { "doc": 
        { chargebackDate: "2019-08-27 15:14:58", 
         recurringDate: "2019-08-27 15:14:58"} 
       }
      })
 }

orders.forEach(o => {
           o[s][d].chargebackDate = Date.parse(o[s][d].chargebackDate);
o[s][d].recurringDate = Date.parse(o[s][d].recurringDate);
    });
pending…
map
var orders = [];
const [s, d] = ["_source", "doc"];


 for (let i = 0; i < 1000000; i++) {
    orders.push(
      { "_source": 
       { "doc": 
        { chargebackDate: "2019-08-27 15:14:58", 
         recurringDate: "2019-08-27 15:14:58"} 
       }
      })
 }

orders = orders.map(o=>{
  o[s][d].chargebackDate = Date.parse(o[s][d].chargebackDate);
o[s][d].recurringDate = Date.parse(o[s][d].recurringDate);
return o
})
pending…

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

0 Comments