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
var values = [],
sum = 0,
i;
/* I think 1000 is a more realistic value than 10000.
*/
for (i = 0; i < 1000; i++) {
values[i] = i+1;
}
/* 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);
}
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 |
For - prefix decrement, gt0 |
| ready |
For - prefix decrement, not equal |
| ready |
For - prefix decrement, gt |
| ready |
For - prefix uq -1 |
| ready |
For - gt -1 |
| ready |
For with assignment |
| ready |
for post-decrement statement |
| ready |
for pre-decrement count |
| ready |
for pre-decrement statement, --i!==-1 |
| ready |
While, body pre-decrement |
| ready |
For with assignment - sum increment |
| ready |
For with assignment, shorthand |
| ready |
For with assignment, sum increment, shorthand |
| ready |
Inverse For with decrement-assignment, shorthand using add-function |
| ready |
Inverse For with decrement-assignment, shorthand, sum up |
| ready |
Inverse For with assignment and decrement count, shorthand using add-function |
| ready |
Inverse For with assignment and decrement count, shorthand, sum up |
| ready |
for in shorthand |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.