1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    118
    Vote Rating
    9
    Bunchofstring will become famous soon enough

      0  

    Default How can I Batch Operations?

    How can I Batch Operations?


    I have a bunch of objects that I want to create records from and save to localStorage. Model + Store + Proxy... all good there, but if I have a LOT of objects to save (e.g. 5000), how can I make sure the records all get built, THEN saved all at once to localStorage really quickly?

    My guess is that if I do it in batch, localStorage writes will block the thread for less time.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,642
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Don't have autoSync set to true. Create your records and then do a store.sync() and it will sync all changes to the store at once.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    118
    Vote Rating
    9
    Bunchofstring will become famous soon enough

      0  

    Default


    Thanks @Mitchell, but I'm not seeing any improvement when I follow your advice. Is there something else I could be doing wrong? Here are the numbers I'm seeing in Chrome on my year-old MacBook Pro (i7). Adding just over 3000 records with about 5 fields per record is taking:

    ~60 seconds with autoSync turned on
    ~60 seconds if I turn autoSync off, add the records, then sync
    ~1/4 of a second with no syncing at all

    At just over 50 records/second, I have to assume I'm doing something horribly wrong.
    Please help

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    118
    Vote Rating
    9
    Bunchofstring will become famous soon enough

      0  

    Default


    @Mitchell, I created a test case that better represents what I'm talking about. It compares the performance of the OOTB behavior (for each record, encode, then write) against pre-encoding all of the key->value records in a batch then writing them all at once. I would be grateful for any comments or advice.

    http://jsperf.com/bos-1/2

  5. #5
    Sencha User
    Join Date
    Nov 2010
    Posts
    118
    Vote Rating
    9
    Bunchofstring will become famous soon enough

      0  

    Default


    Bump

Thread Participants: 1

Tags for this Thread