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 to see if redefining function methods are slower when called repeatedly vs having them defined once on the object and then accessing it
var objFnSameLevel = {
method1: function(arg1, arg2) {
return arg1 + arg2;
}
, method2: function(myArg) {
return myArg + 2;
}
, method3: function(myArg) {
return this.method1(myArg, this.method2(myArg));
}
};
var objFnNested = {
methods: function(myArg) {
var thisArg = myArg;
var method1 = function(arg1, arg2) {
return arg1 + arg2;
};
var method2 = function(myArg) {
return myArg + 2;
};
var method3 = function(myArg) {
return method1(myArg, method2(myArg));
};
return method3(thisArg);
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Functions on same level as object, defined once and accessed |
| ready |
Functions nested, redefined each time |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.