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 sideffect;
var firstarray = [];
var secondarray = [];
(function(){
'use strict';
for (var i = 0; i < 100; i++) {
firstarray[i] = Math.floor(Math.random() * 11);
}
for (var i = 0; i < 100; i++) {
secondarray[i] = Math.floor(Math.random() * 11);
}
})();
</script>
<script>
(function() {
'use strict';
function usingvar() {
for (var i = 0; i < 100; ++i) {
var firstnumber = firstarray[i];
for (var j = 0; j < 200; ++j) {
var secondnumber = secondarray[j%100] + 5;
var total = firstnumber + secondnumber;
sideffect = total;
}
}
for (var i = 0; i < 100; ++i) {
var firstnumber = firstarray[i];
for (var j = 0; j < 200; ++j) {
var secondnumber = secondarray[j%100] + 5;
var total = firstnumber + secondnumber;
sideffect = total;
}
}
}
window.usingvar = usingvar;
})();
</script>
<script class="usinglet" type="application/javascript;version=1.8">
(function() {
'use strict';
function usinglet() {
for (let i = 0; i < 100; ++i) {
let firstnumber = firstarray[i];
for (let j = 0; j < 200; ++j) {
let secondnumber = secondarray[j%100] + 5;
let total = firstnumber + secondnumber;
sideffect = total;
}
}
for (let i = 0; i < 100; ++i) {
let firstnumber = firstarray[i];
for (let j = 0; j < 200; ++j) {
let secondnumber = secondarray[j%100] + 5;
let total = firstnumber + secondnumber;
sideffect = total;
}
}
}
window.usinglet = usinglet;
})();
</script>
<script>
if ( !/Gecko\//.test(navigator.userAgent) ) {
var script = document.querySelector('script.usinglet');
script.removeAttribute('type');
var parent = script.parentElement;
parent.removeChild(script);
parent.appendChild(script);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
var |
| ready |
let |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.