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
Compares locally defined functions and globally defined functions.
Revision 2: Added "closed local" test that only defines "helper" once, unlike "local", which defines it every call.
<script>
function foo1() {
var helper = function(val) {
return val * val * Math.sin(val);
}
var obj = [];
for (var i = 0; i < 10; i++) {
obj[i] = helper(i);
}
}
function foo2() {
var obj = [];
for (var i = 0; i < 10; i++) {
obj[i] = helper(i);
}
}
function helper(val) {
return val * val * Math.sin(val);
}
var foo3 = (function() {
function helper(val) {
return val * val * Math.sin(val);
}
return function() {
var obj = [];
for (var i = 0; i < 10; i++) {
obj[i] = helper(i);
}
};
});
function runFoo1() {
for (var i = 0; i < 100; i++) {
foo1();
}
}
function runFoo2() {
for (var i = 0; i < 100; i++) {
foo2();
}
}
function runFoo3() {
for (var i = 0; i < 100; i++) {
foo3();
}
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
local |
| ready |
global |
| ready |
closed local |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.