Backbone.js Collection iteration

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script src=""></script>
<script src=""></script>
Benchmark.prototype.setup = function() {
    var M = Backbone.Model.extend({ });
    var Col = Backbone.Collection.extend({
      model: M
    var a = new Array(5000);
    var c = new Col(a);

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 each
for (idx in c) {
    var m = c[idx];
for loop with
for (var i = 0, l = c.length; i < l; i++) {
for loop with collection.models
for (var i = 0, l = c.length; i < l; i++) {

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment