jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
What is the fastest loop for function call ?
var values = [];
for (var i = 0; i < 1000; i++)
values[i] = i+1;
//sum is reset before test to guarantee same condition
var sum;
function add (val) {
sum += val;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
forEach |
| ready |
for in |
| ready |
for(i=0;i<L;i++) |
| ready |
for(i=L-1;i>=0;--i) |
| ready |
for(i=L-1;i>=0;i--) |
| ready |
for(i=L-1;i!==0;i--) |
| ready |
for(i=0;i<L;i++) |
| ready |
for(;i!==L;) |
| ready |
for(i=0;i<L;i++) call() |
| ready |
for(i=L-1;i!==0;--i) |
| ready |
for(i=L;--i>=0;) |
| ready |
for(i=L;--i!==-1;) |
| ready |
for(i=L;i;) |
| ready |
for(i=L;i--;) |
| ready |
for(i=L;i;--i) |
| ready |
for(i=L;--i!==-1;) |
| ready |
while(i--!==-1) |
| ready |
while(--i>=0) call() |
| ready |
while(i-->0) |
| ready |
while(i<L) |
| ready |
while(i) |
| ready |
while(i!==L) |
| ready |
while(--i>=0) |
| ready |
while(--i) |
| ready |
while(--i!==0) |
| ready |
for(i=0;match=values[i];++i) |
| ready |
for(i=L-1;match=values[i];--i) |
| ready |
for(i=L;match=values[--i];) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.