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
Performance of LiquidLava generated classes is equal to their hand-written analogues.
You can see that construction is slower - that is due to the following line, which is present in generated constructors, and not present in native:
var r=Lava.ClassManager.getClassData('...').references;
When size of classes increase - this line plays less role, and construction speed becomes equal to native.
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.5.1/mootools-yui-compressed.js"></script>
<script src="http://lava-framework.com/lib/lava-master-DEBUG.js"></script>
<script>
// create classes in traditional way
function NativeParentClass() { this.counter = 0; }
NativeParentClass.prototype.parentMethod = function() { this.counter++; }
function NativeChildClass() {}
NativeChildClass.prototype = new NativeParentClass();
NativeChildClass.prototype.childMethod = function() { this.parentMethod(); }
var NativeInstance = new NativeChildClass();
// Create classes via Lava.ClassManager
Lava.ClassManager.registerRootNamespace('window', window);
Lava.ClassManager.define(
'window.LavaParentClass',
{
counter: 0,
parentMethod: function() { this.counter++; }
});
Lava.ClassManager.define(
'window.LavaChildClass',
{
Extends: 'window.LavaParentClass',
childMethod: function() { this.parentMethod(); }
});
var LavaInstance = new LavaChildClass();
// the same classes, but generated on server
Lava.ClassManager.loadClass({
name: "LavaServerParent",
path: "window.LavaServerParent",
level: 0,
"extends": null,
"implements": [],
hierarchy_paths: ["window.LavaServerParent"],
parent_class_data: null,
prototype_generator: function(cd,p) {
var r=cd.references,
s=cd.shared;
p.Class = cd;
p.counter = 0;
p.parentMethod = r[0];
},
shared: {},
references: [function () { this.counter++; }],
constructor: function() {
var r=Lava.ClassManager.getClassData('window.LavaServerParent').references;
}
});
Lava.ClassManager.loadClass({
name: "LavaServerChild",
path: "window.LavaServerChild",
level: 1,
"extends": "window.LavaServerParent",
"implements": [],
hierarchy_paths: [
"window.LavaServerParent",
"window.LavaServerChild"
],
parent_class_data: null,
prototype_generator: function(cd,p) {
var r=cd.references,
s=cd.shared;
p.Class = cd;
p.childMethod = r[1];
p.counter = 0;
p.parentMethod = r[0];
},
shared: {},
references: [function () { this.parentMethod(); }],
constructor: function() {
var r=Lava.ClassManager.getClassData('window.LavaServerChild').references;
}
});
var ServerInstance = new LavaServerChild();
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Native class creation |
| ready |
Lava class creation (client generated class) |
| ready |
Lava class creation (server-side generated class) |
| ready |
Native method call |
| ready |
Lava method call (client generated class) |
| ready |
Lava method call (server generated class) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.