XML::Parser or XML::LibXML?

That’s an easy question to answer: XML::LibXML!

I have over 10,000 lines of XML input. Parsing it into a tree with XML::Parser takes about 0.77 seconds, while XML::LibXML is over ten times faster, clocking in at 0.07 seconds.

#!/usr/bin/perl
use strict;
use Benchmark qw( cmpthese timethese :hireswallclock );
use XML::Parser;
use XML::LibXML;

sub xml_parser {
    my $p1 = new XML::Parser(Style => 'Tree');
    my $tree = $p1->parsefile('database.xml');
}

sub xml_libxml {
    my $p1 = new XML::LibXML;
    my $tree = $p1->parse_file('database.xml');
}

my $results = timethese(15,
    {<tt>
        'XML::LibXML' =&gt; \&amp;xml_libxml,
        'XML::Parser' =&gt; \&amp;xml_parser,
    },
    'noc',
);
print "\n";
cmpthese($results);

The results are pretty damning:

XML::LibXML: 1.06607 wallclock secs ( 1.01 usr +  0.03 sys =  1.04 CPU) @ 14.42/s (n=15)
XML::Parser: 11.5305 wallclock secs ( 9.20 usr +  1.14 sys = 10.34 CPU) @  1.45/s (n=15)

              Rate XML::Parser XML::LibXML
XML::Parser 1.31/s          --        -91%
XML::LibXML 14.4/s       1005%          --

Now it’s off to write a schema for our wondrous XML dialect.

Fotozondagavond #37: Scary/Creepy/Narrow (“Eng”)

I figured I’d find some spiders and do a close-up of them, but then I realised they don’t scare me at all. Death does scare me a bit, but the Grim Reaper was not willing to pose.

In any case, last week we did have something that classifies as scary as well as narrow…

Take a look at this:

Scary #1 Scary #2

This is what Betta discovered last week when cleaning out one of our wardrobes. Note that the carpet and chipboard have already been removed here: the water had soaked through those and created mouldy patches. On first inspection we suspected a leaky pipe in the wall, but that wasn’t the problem.

I decided to take a peek under the floor in the crawl space (click to enlarge):


Kinda looks ok..
But, wait! What’s that?

Yep, the water from this tiny leak had been spraying against the bottom of our floor for who knows how long, soaking the wooden beams thoroughly.

Fortunately, a plumber was able to fix it in no time and now we have to wait for the floor to dry before we can cover it again.

Also, the plumber mentioned that the only piece of lead pipe we still have is from the front door to that leak. The rest (including
the pipe going up to the other appartments) is already made of copper. So replacing that piece of lead is going to be relatively
painless and quick.