I'm working on a project where I'd like to work with some simple (less than 2KB) XML files. I've been happily chugging along with XML::Simple in previous projects but this one requires that total run time is as low as possible.

Just for some testing purposes, I used the XML output of a Shoutcast server. It is about 5KB, more than twice the size of my files. I measured times with Time::HiRes. WinXP, AMD XP 1700, 512 PC2100, it took .16 seconds to parse the file with XML::Simple. I was shocked. I was expecting maybe two or three hundredths, but not two tenths. Chopping out some of the contents of the XML file, I cut the size in half. Same thing, .16 seconds.

At this point I'm freaking out, thinking that the Shoutcast XML output must be malformed and giving XML::Simple a hard time. I caved in and used the example straight out of the XML::Simple POD. 0.16 seconds. That really isn't acceptible for this application. I've tried messing with XML::Parser but ::Simple's limitations (except execution time) are absolutely no issue to me.

If I use XML::Parser, removing the ::Simple overhead, will I notice a speed improvement? Is there an XML module popularly used specifically for its speed?
I've looked a bit at XML::Parser and it seems 95% overkill for my needs, but if figuring out how to adapt it will save me time, I'll be going with that option.

While I'm here .. ;) .. is there any benefit of keeping the XML chunks in a mySQL table? My thinking is that over time, as the number of XML files increase, the seek time for that table will increase. Keeping individual files will put the seeking on a lower level and keep it quick.

Thanks,
-billyak

In reply to XML(::Simple) Parsing Efficiency by billyak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.