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
Added simple function invocation and tailored the tests to suite the blog post I was writing. Plus added calls to the methods.
The most important thing to remember is to use the right tool for the job. All these tests do is reference an object with a complex memory allocation. When you don't need something fancy, you're better off using a regular old object
// Setup function constructor.
var AFunctionConstructor = function () {
var myString = 'a string';
var foo = function () {
return myString;
};
this.bar = function () {
return foo();
};
};
// Setup function constructor with functions added to the prototype.
var AFunctionConstructorWithPrototypeAdditions = function () {
this.myString = 'a string';
};
AFunctionConstructorWithPrototypeAdditions.prototype.foo = function () {
return this.myString;
};
AFunctionConstructorWithPrototypeAdditions.prototype.bar = function () {
return this.foo(); // think we need this here.
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Simple function invocation. |
| ready |
Function constructor invocation. |
| ready |
Function constructor invocation with functions added to the prototype. |
| ready |
Object literal invocation. |
| ready |
Simple function invocation. Plus method call. |
| ready |
Function constructor invocation. Plus method call. |
| ready |
Function constructor invocation with functions added to the prototype. Plus method call. |
| ready |
Object literal invocation. Plus method call. |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.