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
I've always been curios about bound contextes against lookup
// forced native
Function.prototype.$bind = function () {
var self = this;
return function bound() {
return self.call(self);
};
};
// native where present
"bind" in Function.prototype || (Function.prototype.bind = Function.prototype.$bind);
// helper
function set(obj, value) {
if (Object.defineProperty) {
Object.defineProperty(obj, "value", {get:value});
} else if (obj.__defineGetter__) {
obj.__defineGetter__("value", value);
} else {
// do not consider in IE < 9
obj.value = function () {};
}
}
var bound = function () {
return this.value;
};
bound.value = Math.random();
var native = bound.bind(bound);
var lookup = function () {
return bound.value;
};
var simulate = bound.$bind(bound);
var i = 0;
var noJIT_bound = function () {
return this.value;
};
set(noJIT_bound, function () {
return ++i;
});
var noJIT_native = noJIT_bound.bind(noJIT_bound);
var noJIT_lookup = function () {
return noJIT_bound.value;
};
var noJIT_simulate = noJIT_bound.$bind(noJIT_bound);
var result;
Ready to run.
Test | Ops/sec | |
---|---|---|
native |
| ready |
lookup |
| ready |
simulate |
| ready |
no JIT native |
| ready |
no JIT lookup |
| ready |
no JIT simulate |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.