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
Test "call()" vs "apply()" vs calling functions directly (with and without closure).
function Obj() {
this.that = "that";
var _this = this;
this.directClosure = function(v) {
_this.that = v;
};
}
Obj.prototype.test = function(val) {
this.that = val;
};
Obj.prototype.wrapFunc = function(func) {
this.invokeWrappedFunc = eval("var _this = this; (" + func + ")");
}
Obj.prototype.wrapFunc2 = function(func) {
this.invokeWrappedFunc2 = new Function("_this", "return (" + func + ")");
}
var o = new Obj();
o.wrapFunc(function(v) {
_this.that = v;
});
o.wrapFunc2(function(v) {
_this.that = v;
});
Ready to run.
Test | Ops/sec | |
---|---|---|
apply |
| ready |
call |
| ready |
direct |
| ready |
Wrapped Func (eval) |
| ready |
Wrapped Func (new Function) |
| ready |
Direct Closure |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.