JS MVC Frameworks
JavaScript performance comparison
Preparation code
<div id="container"></div>
<script src="http://sb.taurus.uberspace.de/jslib/jquery-1.7.1.min.js"></script>
<script src="http://sb.taurus.uberspace.de/jslib/underscore-1.3.1.min.js"></script>
<script src="http://sb.taurus.uberspace.de/jslib/handlebars.1.0.beta.5.js"></script>
<script src="http://sb.taurus.uberspace.de/jslib/ember-0.9.5.min.js"></script>
<script src="http://sb.taurus.uberspace.de/jslib/spine-1.0.6,min.js"></script>
<script src="http://sb.taurus.uberspace.de/jslib/backbone-0.9.2.min.js"></script>
<script>
var sharedData = {
header: "Header",
header2: "Header2",
header3: "Header3",
header4: "Header4",
header5: "Header5",
list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
},
container = $("#container");
Handlebars.template((function(){var a=Handlebars.template,b=Handlebars.templates=Handlebars.templates||{};b.handlebarsTemplatePrecompiled=a(function(a,b,c,d,e){function p(a,b){var c="",d;return c+="<li class='item'>",d=a,typeof d===l?d=d.call(a,{hash:{}}):d===n&&(d=m.call(a,"this",{hash:{}})),c+=o(d)+"</li>",c}c=c||a.helpers;var f="",g,h,i,j,k=this,l="function",m=c.helperMissing,n=void 0,o=this.escapeExpression;f+="<div><h1 class='header'>",i=c.header,g=i||b.header,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header",{hash:{}})),f+=o(g)+"</h1><h2 class='header2'>",i=c.header2,g=i||b.header2,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header2",{hash:{}})),f+=o(g)+"</h2><h3 class='header3'>",i=c.header3,g=i||b.header3,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header3",{hash:{}})),f+=o(g)+"</h3><h4 class='header4'>",i=c.header4,g=i||b.header4,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header4",{hash:{}})),f+=o(g)+"</h4><h5 class='header5'>",i=c.header5,g=i||b.header5,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header5",{hash:{}})),f+=o(g)+"</h5><h6 class='header6'>",i=c.header6,g=i||b.header6,typeof g===l?g=g.call(b,{hash:{}}):g===n&&(g=m.call(b,"header6",{hash:{}})),f+=o(g)+"</h6><ul class='list'>",i=c.list,g=i||b.list,h=c.each,j=k.program(1,p,e),j.hash={},j.fn=j,j.inverse=k.noop,g=h.call(b,g,j);if(g||g===0)f+=g;return f+="</ul></div>\n",f})})());
function emberJS() {
var model = Ember.Object.extend();
var instance = model.create(sharedData);
instance.set("header6", "Header6");
return instance.get("header6");
};
function spineJS() {
var model = Spine.Model.sub();
model.configure("Model", "header", "header2", "header3", "header4", "header5", "header6", "list");
var instance = new model(sharedData);
instance.header6 = "Header6";
return instance.header6;
};
function backboneJS() {
var model = Backbone.Model.extend(),
instance = new model(sharedData),
view = Backbone.View.extend({
el: container,
template: Handlebars.templates.handlebarsTemplatePrecompiled,
initialize: function() {
this.model.bind('change', this.render, this);
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
}
});
$(function() {
var app = new view({model: instance});
app.render();
instance.set("header6", "Header6");
});
}
</script>
<script>
Benchmark.prototype.teardown = function() {
container.empty();
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
ember JS |
|
pending… |
spine JS |
|
pending… |
backbone JS |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Tobias Otte
- Revision 2: published by Tobias Otte
- Revision 3: published by Tobias Otte
- Revision 4: published by Tobias Otte
- Revision 5: published by Tobias Otte
- Revision 6: published by Tobias Otte
- Revision 7: published by Tobias Otte
- Revision 8: published by Tobias Otte
- Revision 9: published
- Revision 10: published
0 comments