Test name | Executions per second |
---|---|
reduce | 76.0 Ops/sec |
loop | 4.2 Ops/sec |
loop2 | 4.2 Ops/sec |
t=new Array(500000);
for (let i=0;i<t.length;i++) {t[i]=Math.random();}
t.reduce((p,c) => p+c, 0);
(() => {
let i=0, res = 0;
for (;i<t.length;i++) res += t[i];
return res;})();
(() => {
var i, res;
for (i=res=0;i<t.length;i++) res += t[i];
return res;})();