On 28 Jan 2000, Randal L. Schwartz wrote:

> Have you looked at the new XS version of HTML::Parser?

        Not previously, but I just did.

> It's a speedy little beasty.  I dare say probably faster than even
> expat-based XML::Parser because it doesn't do quite as much.

        But still an order of magnitude slower than mine.  For a test,
        I downloaded Yahoo!'s home page for a test HTML file and wrote
        the following code:

----- test code -----
#! /usr/local/bin/perl

use Benchmark;
use HTML::Parser;
use HTML::Tree;

@t = timethese( 1000, {
   'Parser' => '$p = HTML::Parser->new(); $p->parse_file( "/tmp/test.html" );',
   'Tree'   => '$html = HTML::Tree->new( "/tmp/test.html" );',
} );
---------------------

        The results are:

----- results -----
Benchmark: timing 1000 iterations of Parser, Tree...
    Parser: 37 secs (36.22 usr  0.15 sys = 36.37 cpu)
      Tree:  7 secs ( 7.40 usr  0.22 sys =  7.62 cpu)
-------------------

        One really can't compete against mmap(2), pointer arithmetic,
        and dereferencing.

        - Paul

Reply via email to