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
In reference to a JSFiddle (http://jsfiddle.net/codernator/xaPPw/3/) in which is defined a function to dynamically create function-chainging on an object. Compares the performance of using chain method in Function constructor vs. simply defining chained functions in a prototype pattern.
Note that the functions in the test objects don't actually do anything.
// Assign an anonymous function to instance[funcName] that executes
// either baseHandler, or the existing instance[funcName] (if baseHandler
// is not provided) and then returns instance. This allows creates the
// ability to chain function calls together on the same instance.
function chain(instance, funcName, baseHandler) {
if (!baseHandler && !instance.hasOwnProperty(funcName)) {
throw "function does not exist in instance.";
}
var handler = baseHandler || instance[funcName];
if (typeof handler !== "function") {
throw "Specified funcName or base does not correspond to a function.";
}
instance[funcName] = function () {
handler.apply(instance, arguments);
return instance;
};
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Nested Function Object |
| ready |
Prototype Object - Manual Chaining |
| ready |
Hybrid |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.