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
Simplified conditions to demonstrate that while concise it rarely offers a speed improvement. Code readability is improved with a condition (and will allow you to traverse forward on an array instead of straight down) and no loss of speed.
<script>
var i, values = [],
sum = 0;
for (i = 0; i < 10000; i++) {
values[i] = i;
}
function add(val) {
sum += val;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
ForEach |
| ready |
for loop, simple |
| ready |
for loop, cached length |
| ready |
for loop, reverse |
| ready |
for loop, cached length, no callback |
| ready |
for loop, cached length, using function.call and supplying index and original array |
| ready |
While, reversed + simple |
| ready |
While, reversed + complex callback |
| ready |
While, reversed, simple callback |
| ready |
While, forwards, simple callback |
| ready |
While, reverse, simplified test |
| ready |
While, reverse, simplified test, complex callback |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.