Test name | Executions per second |
---|---|
reduce | 120.4 Ops/sec |
loop | 5.3 Ops/sec |
loop2 | 5.3 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;})();