View Full Version : Convert VS store.each

3 Aug 2012, 8:48 AM
This is just a quick post for anyone who may need to set derived data into the models in a large dataset.

I have just over 1100 items I load from xml, one of the fields (distance) requires some math that I have to calculate each time the store loads. I did quite a bit of playing around with how to make the about 6-8 load faster when I remember the convert function.

I originally added a load listener that would run over each item:

store.each(model) {

Then I removed all the listeners and added to the model:

fields : [{
name : 'distance',
type : 'float',
// The key
convert : function(value, record) {
// calculate distance and return.

Cut about 4 seconds off the load time...I am consistently under 2 seconds (on my machine...devices will still probably suffer a little).

Anyone looking to add a little performance though should remember that! I know I'll keep it in the back of my mind from here out.


6 Aug 2012, 5:44 AM
Do you understand why it's faster?

8 Aug 2012, 5:51 AM
I don't, nor have I really had time to dig into the source.

Do you have a reference I could dig into?