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.

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' =&gt; \&amp;xml_libxml,
        'XML::Parser' =&gt; \&amp;xml_parser,
print "\n";

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.

My friends went to Berlin…

… and all I got was this tiny T-shirt.

Tiny Front
Tiny Back

This once again shows that sizes “S”, “M”, “L”, “XL” are relative sizes, the absolute measures depending on the intended market. This T-shirt is supposedly size “M”. I generally fit in U,S. “M” and sometimes in Dutch “M”. However, this seems to be manufactured in France or Italy, where “M” seems to stand for “Midget”.

Never mind though, Elisabetta was very happy with it. 🙂

Hurling excrement: Ubuntu

This week’s turd goes to Ubuntu whose bleeding edge development version (the “Gutsy Gibbon”) contains a version of GNU coreutils from over a year old. C’mon guys! You don’t have to follow upstream minute-by-minute, but running one year and a major version number behind (5.97 vs. 6.9) is just ridiculous. My beef? The pre-6 releases do not contain the “base64” utility which I really need for some KVM related stuff.

Oh, and a fart in the direction of Fedora, which still ships zsh-4.2. Admitted, 4.3 is “unstable” but it’s running fine on most other distros (see Ubuntu? Some things do get synced with upstream), and at least the Unicode stuff is fixed.

I’m cranky.

Fatlabel – modify DOS volume labels on Linux/UNIX

When inserting USB keys and memory cards on my Linux laptop they are automatically mounted and labeled with whatever name is on the (v)fat volume. I sometimes like to change that. Strangely enough, there is no standard utility for Linux/UNIX to change the volume name of a (v)fat partition.

Not that it’s difficult… I found a good explanation of how the (V)FAT boot sector is structured and managed to write a little perl script around it to manipulate the volume label.


Documentation is included. After installing, ”man fatlabel” should give you the dirt.