Backbone Model Test

JavaScript performance comparison

Revision 2 of this test case created by Karl Purkhardt

Preparation code

<div id="container"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.9/backbone-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.rc.1/handlebars.min.js"></script>

<script>
    var dataList = [];
    for (var i = 0; i < 100; i++) {
        dataList[dataList.length] = i;
    };

    function backboneJS() {
        templateBackbone = Handlebars.compile("{{#each list}}{{/each}}");

        var collection = new Backbone.Collection();

        for (var i = 0; i < dataList.length; i++) {
            collection.add(new Backbone.Model({number: dataList[i]}));
        }

        var View = Backbone.View.extend({
            el: '#container',
            render: function() {
                var contents = templateBackbone({list: this.collection.toJSON()});
                this.$el.html(contents);
            }
        });

        $(function() {
            var app = new View({collection: collection});
            app.render();
        });
    }
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Backbone
backboneJS();
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:

0 comments

Add a comment