Peformance when creating lots of objects


#1

So I’m writing my own data layer to use until ember data meets our performance requirements. So far its working much better, but there is still a noticeable freeze as its processing the data from the xhr requests. Here is what my findAll method looks like:

	findAll: function() {
		var url = this.url,
			newObjects = [],
			root = this.root + 's',
			self = this;

		newObjects.set('isLoaded', false);

		if(this.plural) {
			root = this.plural;
		}

		$.getJSON(url).then(function(response) {
			var temp  = [];
			response[root].forEach(function(data) {
				temp.addObject(self.create(data));
			});

			Ember.run(self, function () {
				newObjects.addObjects(temp);
				newObjects.set('isLoaded', true);
			});
			
		});

		return newObjects;
	}

Is there anything I can do better in this code to get more performance out of it?


#2

Could you create a sample app that demonstrates the freeze? I can’t make any suggestions until I can run this through a profiler.


#3

Thanks @nerdyworm. I’ll try to get an example up as quick as I can, likely not till over the weekend though.