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
This is a simple bake off for checking loop speed with pre-initalized and cached vars vs more 'free form, on the fly loops'
<script>
var long_arr=new Array(100), item;
function cached_loop(arr) {
var lst=arr, l=lst.length, i=0;
for( ; i<l; i++) {
item=lst[i]
}
}
function uncached_loop(arr) {
for(var i=0; i<arr.length; i++) {
item=arr[i];
}
}
function shorthand_syntax_loop(arr) {
for(var i=0, l=arr.length; i<l; i++) {
item=arr[i]
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Local Variable Store |
| ready |
Check length Each Time |
| ready |
Shorthand Loop Syntax |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.