• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speeding up creation of NSDictionary from XML? (iTunes related)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Speeding up creation of NSDictionary from XML? (iTunes related)
      • From: Michael Rothwell <email@hidden>
References: 
 >Speeding up creation of NSDictionary from XML? (iTunes related) (From: Jonathan del Strother <email@hidden>)

  • Prev by Date: Speeding up creation of NSDictionary from XML? (iTunes related)
  • Next by Date: Re: refreshing the header title for an NSTableColumn
  • Previous by thread: Speeding up creation of NSDictionary from XML? (iTunes related)
  • Next by thread: Re: Speeding up creation of NSDictionary from XML? (iTunes related)
  • Index(es):
    • Date
    • Thread