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 started this performance page because we have been facing memory issues with an App. I have used as a base information from the article: http://coding.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/ and then added extra posibilities to implement a better or worst pattern. I hope to see improvements.
Follow Me on Twitter @efsandino
Benchmark.prototype.setup = function() {
var standardObject = {
foo: function(){
log("foo");
},
bar: function(){
log("bar");
}
};
// Implementation of a JS Class with Prototype Pattern
Klass1 = function() {}
Klass1.prototype.foo = function() {
log('foo');
}
Klass1.prototype.bar = function() {
log('bar');
}
// Implementation of a JS Class with Module Pattern
Klass2 = function() {
var foo = function() {
log('foo');
},
bar = function() {
log('bar');
};
return {foo: foo, bar: bar}
}
// Implementation of a JS Class with Module Pattern + Cached Functions
var FooFunction = function() {
log('foo');
};
var BarFunction = function() {
log('bar');
};
Klass3 = function() {
return {foo: FooFunction, bar: BarFunction}
}
// Implements of JS Class with Module Pattern + Dinamyc Functions
Klass4 = function() {
return {
foo:function(){log('foo');},
bar:function(){log('bar');}
}
};
// Implement of JS Class with Module Pattern + Anonymous Functions
var KlassX = (function(){
var my ={};
my.log = function(){log('foo')};
my.bar = function(){log('bar')};
return my;
})();
Klass5 = function(){
return {
log:KlassX.log,
bar:KlassX.bar
}
}
// Implement of JS Class with Module Pattern + Anonymous Cached Functions
var FooFunctionY = function(){
log('foo');
};
var BarFunctionY = function(){
log('bar');
};
var KlassY = ( function(){
var my = {};
my.log = FooFunctionY;
my.bar = BarFunctionY;
return my;
})();
Klass6 = function(){
return {
log:KlassY.log,
bar:KlassY.bar
}
}
} //end braked of JSPerform API do not erase
Ready to run.
Test | Ops/sec | |
---|---|---|
Prototypal |
| ready |
Module Pattern |
| ready |
Module Pattern With Cached Functions |
| ready |
Module Pattern + Dinamyc Functions |
| ready |
Module Pattern + Anonymous Functions |
| ready |
Module Pattern + Anonymous Cached Functions |
| ready |
Use the right tool for the job |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.