XML::Parser or XML::LibXML?

August 28th, 2008

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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,
    {
        'XML::LibXML' => \&xml_libxml,
        'XML::Parser' => \&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")

August 19th, 2008

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):

crawl space
Kinda looks ok..
crawl space
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.


Fotozondagavond #36: Still Life

August 19th, 2008

Late again.

Anyway, you can’t get any stiller than a cat. :-)

Still Life #1

Ok, ok, here’s some more “real” still life…

Still Life #2
Still Life #3
Still Life #4


More stillness:


Fotozondagavond #35: Depth of Field (DOF)

August 8th, 2008

Sunday? More like Friday. Yeah, I’m late.

A wet day last week:

DoF#1

Large aperture, close-up, click, click. Low DOF.

DoF#2 DoF#3 DoF#4

More (or less) DoF at: