1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    92
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default 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:
    Code:
    store.each(model) {
      model.setDistance();
    }
    Then I removed all the listeners and added to the model:
    Code:
    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.

    bwags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    92
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default


    I don't, nor have I really had time to dig into the source.

    Do you have a reference I could dig into?