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
Test the fastest method of checking the existence of remaining content when shifting items from an array.
After seeing the following code in jQuery's Deferred implementation.
try {
while( callbacks[ 0 ] ) {
callbacks.shift().apply( context, args );
}
}
finally {
fired = [ context, args ];
firing = 0;
}
Source: https://github.com/jquery/jquery/blob/1.6.1/src/deferred.js#L58
<script>
// Create an array with 10,000 items.
var array = [], undefined;
for (var i = 0, t = 10000; i < t; i++) {
array[i] = true;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
array.length |
| ready |
array[0] !== undefined |
| ready |
array[0] |
| ready |
Cache length |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.