Test backbone collection speed

JavaScript performance comparison

Revision 7 of this test case created

Preparation code

<script type="text/javascript" src="https://rawgithub.com/jashkenas/backbone/master/test/vendor/json2.js"></script>
<script type="text/javascript" src="https://rawgithub.com/jashkenas/backbone/master/test/vendor/jquery.js"></script>
<script type="text/javascript" src="https://rawgithub.com/jashkenas/backbone/master/test/vendor/underscore.js"></script>
<script type="text/javascript" src="https://raw.github.com/jashkenas/backbone/master/backbone.js"></script>
<script type="text/javascript">
window.Backbone = Backbone.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var startModels = [{ id: 0 }, { id: 1 }, { id: 2 }];
    var source = [];
    var collection = new Backbone.Collection(startModels);
   
    for (var i = 3; i < 1000; ++i) {
        source.push({ id: i });
    }
};

Benchmark.prototype.teardown = function() {
    collection.reset(startModels);
};
</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
Master collection.reset
collection.reset(source);
pending…
Master collection.add
collection.add(source);
pending…
Native add
[].push.apply([], source)
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