Test backbone collection speed

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script type="text/javascript" src="https://rawgithub.com/documentcloud/backbone/master/test/vendor/jquery.js"></script>
<script type="text/javascript" src="https://rawgithub.com/documentcloud/backbone/master/test/vendor/underscore.js"></script>
<script type="text/javascript" src="https://rawgithub.com/documentcloud/backbone/master/backbone.js"></script>
<script type="text/javascript">
window.BackboneMaster = Backbone.noConflict();
</script>


<script type="text/javascript" src="https://rawgithub.com/kuzemchik/backbone/master/backbone.js">
</script>
<script type="text/javascript">
window.BackboneSpeedup = Backbone.noConflict();
</script>
<script>
Benchmark.prototype.setup = function() {
    var startModels = [{id:0},{id:1},{id:2}];
    var speedupCollection = new BackboneSpeedup.Collection(startModels);
    var masterCollection = new BackboneMaster.Collection(startModels);
   
   
   
    /* have to use smaller than 65533 collection because otherwise master code will fail */
    var source = [];
    for (var i = 3; i < 2000; i++) {
      source.push({
        id: i
      });
    }
};

Benchmark.prototype.teardown = function() {
    speedupCollection.reset(startModels);
    masterCollection.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
masterCollection.reset(source);
pending…
Speedup collection.reset
speedupCollection.reset(source);
pending…
Master collection.add
masterCollection.add(source);
pending…
Speedup collection.add
speedupCollection.add(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