-
3 Aug 2012 8:48 AM #1
Convert VS store.each
Convert VS store.each
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:
Then I removed all the listeners and added to the model:Code:store.each(model) { model.setDistance(); }
Cut about 4 seconds off the load time...I am consistently under 2 seconds (on my machine...devices will still probably suffer a little).Code:fields : [{ name : 'distance', type : 'float', // The key convert : function(value, record) { // calculate distance and return. } }]
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.
bwags
-
6 Aug 2012 5:44 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 435
Do you understand why it's faster?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Aug 2012 5:51 AM #3
I don't, nor have I really had time to dig into the source.
Do you have a reference I could dig into?


Reply With Quote