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