Re: XPath seems slow - what am I doing wrong?
by Matt Sergeant other posts by this author
Jul 11 2001 8:03AM messages near this date
view in the new Beta List Site
XPath seems slow - what am I doing wrong?
|
RE: PerlSax to parse/search large (~350 MB) file
On Wed, 11 Jul 2001, John Elbourne - work wrote:
> The following code takes about 2.5 seconds of user processor time on a Sun
> sparc Ultra-4, which seems a long time?
>
> ###################################################
> #! /usr/local/bin/perl -w
> use strict;
> use FindBin;
> use lib ("$FindBin::Bin/../../lib/perl5/site_perl/5.005");
>
> use XML::XPath;
> use XML::Parser;
>
> print '' . (times)[0] . "\n";
>
> my $xp = XML::XPath->new(filename => 'ch1.xml');
>
> print "abstract + reference" if $xp->find('/BIBL');
> print "abstract + full text" if $xp->find('/BDY');
> print "erratum" if $xp->find('/ERRATUM');
> print "letter" if $xp->find('/LETTER');
> print "review" if $xp->find('/REVIEW');
-> find in a boolean context like this has to do a number of things which
slow it down. Try -> findnodes() instead.
--
<Matt/>
/|| ** Founder and CTO ** ** http://axkit.com/ **
//|| ** AxKit.com Ltd ** ** XML Application Serving **
// || ** http://axkit.org ** ** XSLT, XPathScript, XSP **
// \\| // ** mod_perl news and resources: http://take23.org **
\\//
//\ // \
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml
Thread:
John Elbourne - work
Matt Sergeant
|