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
Testing the performance impact of simply referencing the implicit arguments array in a function. Loops are included in the function to minimize the impact of indexing the array and emphasize the impact of simply referring to it.
<script>
function assert(condition) {
if (!condition) throw new Error("Assertion failed!");
}
function f1(a, b, c) {
var d = 0;
for (var i = 0; i < c; i++) {
d += (a + b);
}
return d;
}
function f2() {
var a = arguments[0], b = arguments[1], c = arguments[2], d = 0;
for (var i = 0; i < c; i++) {
d += (a + b);
}
return d;
}
function f3(args) {
var a = args[0], b = args[1], c = args[2], d = 0;
for (var i = 0; i < c; i++) {
d += (a + b);
}
return d;
}
function f4(a, b, c) {
var d = arguments.length;
for (var i = 0; i < c; i++) {
d += (a + b);
}
return d;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
standard argument list |
| ready |
arguments[] |
| ready |
arguments passed as explicit array |
| ready |
only referencing arguments.length |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.