Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'm sure the Mac::PropertyList is slower than hooking into Foundation, but the times you see surprise me. I tried it with my own Album.xml (860kb) and it parsed it in 0.2 seconds. I'm curious hwo long the timed tests (in t/time.t) take for you.

    Also, what else is in the file besides the plist stuff? The only thing I've ever seen above <plist> is the XML declaration, and nothing below </plist>

    A future release of Mac::PropertyList will have the hooks to the foundation stuff so it's faster if tha
    • Brian - i just ran t/time.t and I see this:

      t/time.........Elapsed time is 0.021996
      t/time.........ok

      Pretty consistently at that value.
      I also ran the sample through Devel::DProf and her's what I see:

      macbox:~/tmp thoellri$ perl -d:DProf plist2.pl
      using Mac::PropertyList = 32.427314
      macbox:~/tmp thoellri$ dprofpp
      Total Elapsed Time = 31.58248 Seconds
      User+System Time = 31.01248 Seconds
      Exclusive Times
      %Time ExclSec CumulS #Calls sec/call Csec/c Name
      61.6 19.12 31.044 11456 0.0017 0.0027 Mac::PropertyList::read_next
      34.3 10.65 31.044 708 0.0151 0.0438 Mac::PropertyList::read_dict
      2.20 0.682 0.883 10729 0.0001 0.0001 Mac::PropertyList::Scalar::new
      0.65 0.201 0.201 10729 0.0000 0.0000 Mac::PropertyList::Item::new
      0.64 0.198 0.761 6510 0.0000 0.0001 Mac::PropertyList::read_string
      0.40 0.123 8.925 13 0.0095 0.6866 Mac::PropertyList::read_array
      0.32 0.100 31.154 1 0.1000 31.153 main::loadiPhotoDB
      0.13 0.039 0.233 2797 0.0000 0.0001 Mac::PropertyList::read_real
      0.08 0.024 0.151 1422 0.0000 0.0001 Mac::PropertyList::read_integer
      0.03 0.010 31.054 1 0.0100 31.053 Mac::PropertyList::parse_plist
      0.03 0.010 0.010 2 0.0050 0.0050 DynaLoader::BEGIN
      0.03 0.010 0.010 3 0.0033 0.0033 vars::BEGIN
      0.03 0.010 0.029 4 0.0024 0.0072 main::BEGIN
      0.00 - -0.000 1 - - DynaLoader::dl_install_xsub
      0.00 - -0.000 1 - - Time::HiRes::bootstrap
      macbox:~/tmp thoellri$ perl -MMac::PropertyList -e 'print $Mac::PropertyList::VERSION,qq{\n};'
      1.21

      I see you released 1.23 a few days ago - is it worth testing it with the newer release?

      Looking at this code in Mac::PropertyList::parse_plist
      ...
      # we can handle either 0.9 or 1.0
      $text =~ s|^<\?xml.*?>\s*<!DOC.*>\s*<plist.*?>\s*||;
      $text =~ s|\s*</plist>\s*$||;
      ...
      you can see that the parser will fail to remove the plist-wrapper in case there is no "DOCTYPE" declaration. Well, my AlbumData.xml file (written by iPhoto) does not have a "DOCTYPE" declaration, which means that the first "read_next" will fail because it does not see what it expects to see.
      By removing the wrapper before calling plist_parse I can avoid that problem.

      Fell free to steal as much code as you want - that's why I posted it here ;-)
      • Okay, good to know. I'll fix up the parser.

        The newest version is a fix by Mike Ciul that made things a little bit faster for very large files. It might help.

        What I really need to do is fix up Mike's enhancement so it can deal with files without reading them all in at once. That should be easy, but it's in line after all the other easy things. :)

        After that, I need to add the Foundation stuff (or something similar) so the Mac users don't have to suffer the portability penalty.

        Thanks again :)