Re: Speeding up creation of NSDictionary from XML? (iTunes related)
Re: Speeding up creation of NSDictionary from XML? (iTunes related)
- Subject: Re: Speeding up creation of NSDictionary from XML? (iTunes related)
- From: John Stiles <email@hidden>
- Date: Thu, 10 Nov 2005 10:12:24 -0800
On Nov 10, 2005, at 10:08 AM, Jonathan del Strother wrote:
My app reads the iTunes XML when it launches, and creates an
NSDictionary from it. This takes around 1.6 seconds for my iTunes
library.
I'd like to speed up the app launch time, so have been trying to
figure out ways of reducing this. I figured that if NSDictionary
didn't need to do the text parsing and validation procedures on the
XML, it would be far faster. So my original plan was to load the
XML as normal, then save the new NSDictionary in binary form. On
next launch, if the XML file date hasn't changed, we can just load
the binary form off disk, with no text parsing needed.
I originally tried this with NSKeyedUnarchiver, without much luck -
it was about 0.6 seconds *slower* than reading the xml.
NSUnarchiver did slightly better - 0.15 seconds faster than the xml.
Even so, I'd like it faster if at all possible. (The fact that
iTunes rather frequently bumps the file date on the XML doesn't
help matters, either)
Other than begging the CF team to optimise
CFPropertyListCreateFromXML some more, can anyone think of any
other techniques I might try on this?
You could try using an open source XML parser like Expat and parsing
it yourself. It will be a bit more code, but not a ton--you can
integrate Expat with your app with only a page or two of code. It
just takes a few function callbacks for "tag opened," "tag closed,"
"character data," etc etc. This will give you a lot more control over
how your XML parsing time is spent.
Another option would be to move the XML parse into a separate thread.
This won't make things faster, per se, but it will let the rest of
your app start up gracefully--and on a dual-CPU machine you can get
other tasks done simultaneously as the XML parses. Of course, if you
can't do anything meaningful until the XML is done parsing, this
still isn't a big help.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden