Save Collection

JavaScript performance comparison

Test case created

Info

Does saving the collection object save us any significant time?

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var NUM_RECORDS = 10000; //ten thousand
    var dummyData = new Array();
   
    var CrowdTorch = {};
    CrowdTorch.TestModel = Backbone.Model.extend({});
    CrowdTorch.TestCollection = Backbone.Collection.extend({
      model: CrowdTorch.TestModel
    });
    var collection = new CrowdTorch.TestCollection();
   
    //insert dummy records into collection
    for (var i = 0; i < NUM_RECORDS; i++) {
      var id = i;
      var name = "Name " + i;
      var record = {
        "Id": id,
        "Name": name
      };
   
      dummyData.push(record);
    }
};
</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
New Instantiation
var a = new CrowdTorch.TestCollection(dummyData);
var b = new CrowdTorch.TestCollection(dummyData);
pending…
Use Previous Instantiation
var a = new CrowdTorch.TestCollection(dummyData);
var b = a;
pending…

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

Compare results of other browsers

0 comments

Add a comment