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
Comparing having an event array for firing events, as opposed to just chaining a single function and using that.
/* eventing */
window.events = [];
window.addEvent = function(fn) {
events.push(fn);
}
window.fireEvents = function() {
for (var i = 0; i < events.length; i++)
events[i].apply(null, arguments);
}
/* punching */
Function.chain = function(fn1, fn2) {
return function() {
var output = fn1.apply(this, arguments);
return fn2.apply(this, arguments) || output;
}
}
Function.punch = function(obj, p, fn) {
obj[p] = Function.chain(obj[p], fn);
}
/* event punching */
Function.on = function(obj, p, fn) {
if (obj[p].__ == undefined) {
var _super = obj[p];
obj[p] = function() {
for (var i = 0; i < obj[p].__.length; i++) {
obj[p].__[i].apply(this, arguments);
}
return output;
}
obj[p].__ = [_super];
}
obj[p].__.push(fn);
}
delete window.events;
delete window.punch;
window.events = [];
window.punch = function() {};
Ready to run.
Test | Ops/sec | |
---|---|---|
Eventing |
| ready |
Punching method |
| ready |
Eventing / Punching hybrid |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.