View Full Version : How can I Batch Operations?
21 Aug 2012, 12:06 PM
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.
23 Aug 2012, 4:31 AM
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.
25 Aug 2012, 12:07 AM
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 :((
26 Aug 2012, 4:47 PM
@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.
29 Aug 2012, 5:01 AM
Powered by vBulletin® Version 4.1.5 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.