Test backbone collection speed (v7)

Revision 7 of this benchmark created on


Preparation HTML

<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>

Setup

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 });
    }

Teardown


    collection.reset(startModels);
  

Test runner

Ready to run.

Testing in
TestOps/sec
Master collection.reset
collection.reset(source);
ready
Master collection.add
collection.add(source);
ready
Native add
[].push.apply([], source)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.