Skip to content

Commit

Permalink
a handful of model speed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Oct 14, 2010
1 parent e7ce57c commit 500d66b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Expand Up @@ -135,7 +135,7 @@
// Extract attributes and options.
options || (options = {});
if (!attrs) return this;
attrs = attrs.attributes || attrs;
if (attrs.attributes) attrs = attrs.attributes;
var now = this.attributes;

// Run validation if `validate` is defined.
Expand Down
20 changes: 20 additions & 0 deletions test/speed.js
Expand Up @@ -22,4 +22,24 @@
object.trigger('test:trigger2', 1, 2, 3, 4, 5);
});

var model = new Backbone.Model;

JSLitmus.test('Model: set Math.random()', function() {
model.set({number: Math.random()});
});

var eventModel = new Backbone.Model;
eventModel.bind('change', fn);

JSLitmus.test('Model: set Math.random() with a change event', function() {
eventModel.set({number: Math.random()});
});

var keyModel = new Backbone.Model;
keyModel.bind('change:number', fn);

JSLitmus.test('Model: set Math.random() with a key-value observer', function() {
keyModel.set({number: Math.random()});
});

})();

0 comments on commit 500d66b

Please sign in to comment.