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
<script>
var i, values = [],
sum = 0;
/* I think 1000 is a more realistic value than 10000.
*/
for (i = 0; i < 1000; i++) {
values[i] = i;
}
/* if the sum is bigger than 1000 it will be set to 0
** ´cause the value should not be bigger on on the beginning
** of a test as at the beginning of another test before.
*/
function add(val) {
sum == 1000 ? (sum = 0) : (sum += val);
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
ForEach |
| ready |
for loop, simple |
| ready |
for loop, simple (with var) |
| ready |
for loop, cached length |
| ready |
for loop, reverse |
| ready |
for loop, reverse (not equal, with var) |
| ready |
for loop, cached length, no callback |
| ready |
for loop, cached length, no callback (one time „var”, [using var], not equal [len-1] instead of less |
| ready |
for loop, cached length, using function.call and supplying index and original array |
| ready |
While, reversed + simple |
| ready |
While, reversed + simple, leftside --, not linked |
| ready |
While, reversed + callback |
| ready |
While, reversed + callback, -- right side |
| ready |
While |
| ready |
While, one-time var, not equal |
| ready |
simple while |
| ready |
simple while2 |
| ready |
xxx while |
| ready |
while (++i) |
| ready |
i += 1 while |
| ready |
jquery.each |
| ready |
while i++ |
| ready |
while i-- |
| ready |
while i-- 2 |
| ready |
i -= 1 while, not equal |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.