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
In this revision I've updated the tests to call a function rather than count++;
which is then not used.
I did this as in theory it's possible that some browsers will be able to see this variable is unused and optimise out that code so it's never run.
A real world app is unlikely to contain unused code, so this could skew the tests. - Jamie Mason / @GotNoSugarBaby
<script>
var arr = [], obj = {};
(function ()
{
for( var i = 0; i < 1000; i++ ) {
arr[i] = 'value' + i;
obj[i] = 'value' + i;
}
}());
function someFn (ix)
{
return ix * 5 + 1 / 3 * 8;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
arr.forEach |
| ready |
var i in arr |
| ready |
var i in arr (with hasOwnProperty check) |
| ready |
var i in obj |
| ready |
var i in obj (with hasOwnProperty check) |
| ready |
for i < arr.length (without caching) |
| ready |
for i < arr.length (with caching) |
| ready |
for, counting down |
| ready |
while i < arr.length (without caching) |
| ready |
while i < arr.length (with caching) |
| ready |
while, counting down |
| ready |
while, counting down (2) |
| ready |
while, counting down (3) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.